Forums › Forums › Search & Filter Pro › Custom field empty
Tagged: custom fields
- This topic has 5 replies, 2 voices, and was last updated 8 years, 10 months ago by Ross.
-
Ross Moderator(Private) February 15, 2016 at 10:16 pm #37033
I wasn’t aware of any issue like this – I’ll do a test locally and double check.
Thanks
Anonymous(Private) February 15, 2016 at 10:31 pm #37037Hello 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(Private) February 15, 2016 at 11:19 pm #37041Do you have a live example I could look at?
Thanks
Ross Moderator(Private) February 25, 2016 at 4:46 pm #37954Hey 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
-
AuthorPosts