dimanche 22 mai 2016

Order wp_query by Vafpress meta

I'm trying to order a custom-post-type WP_Query by a custom vafpress metabox:

My Metabox

    $mb = new VP_Metabox(array(
        'id'          => 'meta_person',
        'types'       => array('person'),
        'title'       => __('Person informations', 'dr_domain'),
        'priority'    => 'high',
        'template'    => array(
            array(
                'type' => 'textbox',
                'name' => 'person_name',
                'label' => __('Your Name', 'vp_textdomain'),
            ),
            array(
                'type' => 'textbox',
                'name' => 'person_city',
                'label' => __('Your City', 'vp_textdomain'),
            ),

        ),
    ));

I want to retrieve Persons by their city, for that here is my Query:

$args = array(
    'post_type' => 'person',
    'meta_query'=> array(
        array(
            'key' => 'meta_person.person_city',
            'compare' => 'LIKE',
            'value' => 'Paris',
        ),
    ),
);

The WP_Query is not returning any result. I tried this option too, with no results:

'meta_key' => 'person_city' // No Result

So How can I use WP_Query with field and without metabox ID. Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire