Query Post Using Post Option Value Parameter
I have custom post type named 'download' in my theme. I create checkbox option to set this post type as featured download, so when the checkbox checked the download post become featured download. I want to display latest featured download using this post option parameter. This is my wp query but it doesn't work.
$args=array(
'post_type' => 'download',
'posts_per_page'=> 10,
'meta_query' => array(
array(
'key' => 'feature_download',
'value' => '1'
),
),
'ignore_sticky_posts' => 1
);
$my_query = new wp_query($args);
Can you help me? thanks
The framework saves all options in one meta key as serialized array, so you can't query by specific option id.
If you want an option to be saved as separate meta, use the save-in-separate-meta parameter.
You can set this parameter to any option
'option_id' => array(
'type' => 'text',
'save-in-separate-meta' => true,
),
The query for your case will be
$args = array(
'post_type' => 'download',
'posts_per_page'=> 10,
'meta_query' => array(
array(
'key' => 'fw_option:feature_download',
'value' => '1',
),
),
'ignore_sticky_posts' => 1
);
$my_query = new wp_query($args);
I have another question, what is the conditional tag for if this page using builder not the standard WP editor. Thanks.
Hi @blackmekemeke, currently it is tricky to check whether a page is built with the builder or not, we will make a helper function that will do this in a future release.
@blackmekemeke what is the conditional tag for if this page using builder not the standard WP editor
The fw_ext_layout_builder_is_builder_post($post_id = '') helper was added in v1.4.10