I would like to add a shortcode to my header. I know I need to go into my child theme's header.php file and insert the div, when I do this it adds the div when I view the pagesource, but it doesn't add the shortcode? The shortcode is for a search box relating to the Essential Grid plugin i have on the site. The plugin makers (ThemePunch) have said this shortcode will work anywhere, but they won't help me in terms of how to use the do_shortcode() function because it is off-topic for their help forum.

The code i have added to my header is a div with the CSS class .mysearch which is:

<div class="mysearch"> <?php echo do_shortcode('[ess_grid_nav id="search-input" alias="maingrid"]');  ?>  </div>

Am I missing something out here?

Unfortunately this is a localhost site so I don't have a live url to post.

Many thanks in advance for any help


  • That looks good, it should work. Have you tried just [ess_grid_nav] without the parameters? See if they are causing some error. – ngearing Nov 14 '16 at 23:23
  • Hi Nath, I just tried that and it still doesn't work. – Paul12_ Nov 14 '16 at 23:39
  • Are you sure this shortcode exists? Quick test: add_shortcode('ess_grid_nav',function($a){return 'Hello World!'.print_r($a);}); – Samuel Elh Nov 14 '16 at 23:48
  • Hi Samuel, I added that in my functions.php (i assume that is where to put it?) and the following printed to my screen in the <header>, which is where I would like the shortcode to be: Array ( [id] => search-input [alias] => maingrid ) Hello World!1 – Paul12_ Nov 14 '16 at 23:54
  • Does [ess_grid_nav] work if you copy-paste those values into the post content of the same page? (sanity checking because that definitely looks like it should work) – Jen Nov 15 '16 at 4:10

Browse other questions tagged or ask your own question.