Support » Fixing WordPress » How do you display the search term that was used above the results

Viewing 6 replies - 1 through 6 (of 6 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    untested if this works with google search;
    http://codex.wordpress.org/Template_Tags/get_search_query

    Matt

    (@bullymaxinc)

    I was reading around and someone with the same issue used the following code:<h1 class="page-title"><?php echo( 'Search Results for: "'); ?><span><?php echo $_GET['q']; ?></span>"</h1> However, I tried to enter it into the search page with no luck. Where do these codes need to be entered? Here is the current code for the search results page:

    <?php get_header(); ?><h1 class="page-title"><?php echo( 'Search Results for: "'); ?><span><?php echo $_GET['q']; ?></span>"</h1>
    <div id="contentarea" class="row">
    	<?php if (get_option(SHORTNAME . '_post_listing_layout') == 'left')
    	{ ?>
    		<aside class="grid_3 left-sidebar">
    			<?php (get_option(SHORTNAME . '_post_listing_sidebar')) ? $sidebar = get_option(SHORTNAME . '_post_listing_sidebar') : $sidebar = "default-sidebar";
    			generated_dynamic_sidebar_th($sidebar);
    			?>
    		</aside>
    		<?php } ?>
    	<div class="<?php echo (get_option(SHORTNAME . '_post_listing_layout') == 'none') ? 'grid_12' : 'grid_9'; ?>">    
    
    <?php if (have_posts()) : ?>
    <script>
      (function() {
        var cx = '008150889077634852566:korkzx0njc8';
        var gcse = document.createElement('script');
        gcse.type = 'text/javascript';
        gcse.async = true;
        gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
            '//www.google.com/cse/cse.js?cx=' + cx;
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(gcse, s);
      })();
    </script>
    <gcse:searchresults-only></gcse:searchresults-only>
    		<?php endif; ?>
    	</div>
    	<?php if (get_option(SHORTNAME . '_post_listing_layout') == 'right')
    	{ ?>
    		<aside class="grid_3 right-sidebar">
    	<?php (get_option(SHORTNAME . '_post_listing_sidebar')) ? $sidebar = get_option(SHORTNAME . '_post_listing_sidebar') : $sidebar = "default-sidebar";
    	generated_dynamic_sidebar_th($sidebar);
    	?>
    		</aside>
    <?php } ?>
    <div class="clear"></div>
    </div>
    <?php get_footer(); ?>
    Evan Herman

    (@eherman24)

    When I run a search on your page I get an ‘error establishing connection with database’ error.

    Matt

    (@bullymaxinc)

    Evan, I just took care of that issue. Thanks

    Christian Chung

    (@christian1012)

    <?php echo $_GET['query']; ?>

    If the search term was “Hello World”, this would would print Hello World to the browser. You can put this where you want it, but the code you tried to copy/paste would insert another h1 tag, and you only want one of them per page.

    Matt

    (@bullymaxinc)

    The ‘error establishing connection with database’ issue that is. I’m still having trouble getting the results to show the search term

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do you display the search term that was used above the results’ is closed to new replies.