Support

Account

Home Forums Front-end Issues ACF's in header.php showing everywhere but on search results page

Solving

ACF's in header.php showing everywhere but on search results page

  • Hi everyone!

    I have put some simple text fields in the header.php (the user can change the displayed telephone number and specify the URL of a button in the header). The values can be filled using an options page I made for the user.

    Works fine, except on search.php search results. Whatever I do, the values are not displayed at all. I’ve disabled all plugins except ACF Pro, still no luck. Any ideas?

    TO BE CLEAR: I am not talking about getting ACF’s to show up in search result, I am talking about ACF’s in header.php, that for some reason do not show up when viewing a search results page.

    Cheers,

    Carsten

  • … never mind, I found the cause of the problem. I’ve used this script:
    http://projects.jesseheap.com/all-projects/wordpress-plugin-tag-search-in-wordpress-23

    which seems to interfere with ACF. Looking to find a workaround.

  • … actually, strike that: I was too quick with drawing conclusions.

    This has nothing to do with the Jesse Heap snippet of code.

    I found that if I use ACF group and use code like this to display a sub item in that group:

    			<?php if( have_rows('site_header', 'option') ): ?>
    				<?php while( have_rows('site_header', 'option') ): the_row(); ?>
    					<?php if(get_sub_field('phone', 'option')) : ?>
    						<div id="phone">
    							<span class="hide-on-phone hide-on-tablet"><?php the_sub_field('phone_header', 'option') ?></span>
    							<a href="tel:<?php the_sub_field('phone_computer', 'option') ?>"><?php the_sub_field('phone', 'option') ?></a>
    						</div>
    					<?php endif; ?>
    				<?php endwhile; ?>
    			<?php endif; ?>

    … that this will not display on a search results page. A bug?

  • Looking at your code and the fact that the values are on an options page, I see no reason that this code should not be executed and show the values on the search result page. The only reason I can come up with is that is code is not loaded in the header for the search results page.

    Do you have a “search.php” template in your theme? Does this template load the file that contains your code in the header?

  • The cause was indeed something else not ACF related, but I’m very very busy at the moment 🙂 Will get back to this post in about a week!

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

You must be logged in to reply to this topic.