Support

Account

Home Forums ACF PRO get_field is not returning value

Helping

get_field is not returning value

    • lihyao

    • June 10, 2020 at 11:12 am

    I using advanced-custom-fields-pro in wordpress to allow wordpress user to type page id they wish to display in web, is there any way to get the data from wordpress user and in backend using wp_query and display the page with the data user entered in advanced-custom-fields-pro?

    Please take note, i named the field as “feature” in plugin. For my case, ‘feature’ can be contain multiple value like 1,2,3,4 so i would like to get my ‘feature’ value in array, what can i do for this?

    $feature = get_field(‘feature’);

    $the_query_featured = new WP_Query( array(
    ‘posts_per_page’ => 2,
    ‘posts_per_page’ => 2,
    ‘nopaging’ => false,
    ‘order’ => ‘DESC’, //’order’ => ‘ASC’,
    ‘orderby’ => ‘date’,
    ‘meta-key’ => $feature,
    ‘page_id’ => $feature,
    ‘post_type’ => ‘any’
    ));

    <?php while ( $the_query_featured->have_posts() ) : $the_query_featured->the_post(); ?>

  • Iā€™m not sure Iā€™m understanding this correctly but if the feature field is a simple text field, it will return plain text. If you need an array, you need to explode the text first (or whatever else) and use that.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.