Skip Navigation

[Resolved] how to add parameters to a query

This support ticket is created 7 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by paulineS 7 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#470996

I am trying to:
I'm trying to make a custom type posts (its title and meta fields) output on a separate page. This page is created without using TOOLSET. I use standart Word Press query - "WP_query" for the page generation.
I add parameteres to the query:

'meta_query' => array(
array(
'key' => 'wpcf-reader-character’,
'value' => ‘Simpified No Pinyin’
)
)

The 'wpcf-reader-character’ field value is stored in the data base in the form of a line:

a:2:{s:64:"wpcf-fields-checkboxes-option-50aefeeb3fd87abda1ab0e2b08df76a6-1";a:1:{i:0;s:20:"Simplified No Pinyin";}s:64:"wpcf-fields-checkboxes-option-7b2fd2239a2df80de227ed74999f4b7d-1";a:1:{i:0;s:21:"Traditional No Pinyin";}}

Wpcf-reader-character field is created with the help of Toolset. It has 4 checkboxes in admin area. Usually it can be 2 chwckboxes set at one time.

I expected to see:
query results have values

Instead, I got:
The query results are empty.

How should I add the parameters to the query, so that I can find custom posts with 'wpcf-reader-character’ having the value 'Simpified No Pinyin’ ?

Thank you very much in advance.

Kindly send your answer to alex.p@mobecls.com

#471189

Dear pauline,

You can use meta_compare => 'LIKE' in the parameters, for example:

'meta_query' => array(
	array(
		'key' => 'wpcf-reader-character',
		'value' => 'Simpified No Pinyin',
		'meta_compare' => 'LIKE'
	)
)

More help:
https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
meta_compare (string) - Operator to test the 'meta_value'. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'NOT EXISTS', 'REGEXP', 'NOT REGEXP' or 'RLIKE'. Default value is '='.

And we do not provide email support, we provide all support only on the forum.

#471251

Dear Luo,

Thank you very much for help.
That really helped!

Kind regards,
Alexander.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.