Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Post Using Post Option Value Parameter #51

Closed
blackmekemeke opened this issue Nov 2, 2014 · 4 comments
Closed

Query Post Using Post Option Value Parameter #51

blackmekemeke opened this issue Nov 2, 2014 · 4 comments
Assignees

Comments

@blackmekemeke
Copy link

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

@ghost
Copy link

ghost commented Nov 2, 2014

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);

@ghost ghost added the question label Nov 2, 2014
@blackmekemeke
Copy link
Author

I have another question, what is the conditional tag for if this page using builder not the standard WP editor. Thanks.

@rockalife
Copy link
Contributor

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.

@ghost ghost assigned rockalife Nov 5, 2014
@ghost
Copy link

ghost commented Nov 6, 2014

@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

@ghost ghost closed this as completed Nov 6, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants