Support

Account

Home Forums General Issues Query on custom fields

Unread

Query on custom fields

  • Hello,

    I’d like to know how I can run a query on my custom fields.
    I already followed this tutorial :
    https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    but nothing is working for me.

    I can give you examples of what I’m trying to achieve :

    I have a custom field called “fonction” that is inside a group called “renseignement_sur_loffre”.

    Here’s what I tried :

    $args = array(
    ‘post_type’ => ‘offre_stage’,
    ‘numberposts’ => -1,
    ‘meta_key’ => ‘renseignement_sur_loffre_fonction’,
    ‘meta_value’ => ‘Gestion’,
    ‘orderby’ => ‘post_date’,
    ‘order’ => ‘DESC’,
    );
    $offres = get_posts($args);

    It returns me an empty value.
    But I have some posts of type “offre_stage” that exist in the database.

    So it seems that my query is wrong…

    Could you please help me ?

    I have to add that “fonction” is of type “select”.
    I have other fields that I will have to add inside the query that are from different types : selects, radio buttons and simple text.

    Thanks for your help – I’ve been struggling for hours !

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.