Custom field empty

Forums › Forums › Search & Filter Pro › Custom field empty

Tagged: 

Viewing 6 posts – 1 through 6 (of 6 total)
  • Anonymous
    #36817

    Custom fields (ACF) is empty when ajax is enabled, my titles and all custom fields into loop content is empty.

    Example: get_field(‘title_name’,’product_cat_’.$idcat)

    I need help with this.

    Thanks.

    Ross Moderator
    #37033

    I wasn’t aware of any issue like this – I’ll do a test locally and double check.

    Thanks

    Anonymous
    #37037

    Hello Ross,

    I have one example more detail.

    global $wp_query;
    $cat_obj = $wp_query->get_queried_object();
    $catid=$cat_obj->term_id;
    if ( $query->have_posts() )
    {
    $postfounds=$query->found_posts;
    ?>
    <p> <?php echo sprintf(get_field(‘titulo_encontrados’,’product_cat_’.$catid),$postfounds); ?></p>

    Then get_field(‘titulo_encontrados’,’product_cat_’.$catid) is empty when ajax is enabled.

    Thanks for your time.

    Ross Moderator
    #37041

    Do you have a live example I could look at?

    Thanks

    Anonymous
    #37043

    Am sorry, but the project is online and I disable ajax temporally.

    The error is only on results by shortcode.

    Thanks for your help.

    Ross Moderator
    #37954

    Hey Ronald

    I had a quick look – I think the issue is your use of get_queried_object

    https://codex.wordpress.org/Function_Reference/get_queried_object

    If you are using get_queried_object on a regular page (which is where you will place the S&F results shortcode) then get_queried_object will only return data about the current page.

    So the issue here is that this code will never work on a page:

    global $wp_query;
    $cat_obj = $wp_query->get_queried_object();
    $catid=$cat_obj->term_id;

    Hope that makes sense

    Thanks

Viewing 6 posts – 1 through 6 (of 6 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.