Title: Adding shortcode to header.php
Last modified: March 17, 2017

---

# Adding shortcode to header.php

 *  Resolved [3cstudio](https://wordpress.org/support/users/3cstudio/)
 * (@3cstudio)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/adding-shortcode-to-header-php/)
 * Hi Todd, love WOP — trying to add a Text Widget to a site using a child theme
   of Twenty Seventeen. It is to be a custom tagline up on the hero image. I can’t
   get it to render whatsoever — is there a specific protocol I should follow to
   get that text to overlay that header image?
 * Here’s what I did:
    - created a WOP named ‘homepage-mission’
    - added my text sentence into that Text Widget under:
       [widgets_on_pages id=”
      homepage-mission”] in: Appearance > Widgets
    - in header.php, I added the middle line of code:
    -     ```
          		<?php get_template_part( 'template-parts/header/header', 'image' ); ?>
          		<div class="mission-widget"><?php do_shortcode( '[widgets_on_pages id="homepage-mission"]' ); ?></div>
      
          		<?php if ( has_nav_menu( 'top' ) ) : ?>
          ```
      
    - … and I get Nothing. Can you guide me toward getting that widget to show in
      the header?
    - Thanks in advance!
    - Steve C.
       3Cstudio

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/adding-shortcode-to-header-php/#post-8930131)
 * Hi Steve,
 * This should be all possible, using the template tags provided with the Widgets
   on Pages plugin.
 * Could you try something like this, please?
 * `<?php widgets_on_template("homepage-mission"); ?>`
 * If you’re still having no luck then please ping a link up, if you can.
 * Oh, and note that this should at least output something to the DOM, but we might
   need to add some CSS to get it showing just right.
 * Ta, Todd
    -  This reply was modified 9 years, 2 months ago by [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/).
 *  Thread Starter [3cstudio](https://wordpress.org/support/users/3cstudio/)
 * (@3cstudio)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/adding-shortcode-to-header-php/#post-8934529)
 * Thanks Todd — I ended up doing a few things to get it showing:
    – moved it ahead
   of the code for the header image – added the term ‘echo’ to the snippet (thanks
   to a buddy’s 2nd pair of eyeballs) – gave it z-index and absolute position elements
 * Thanks for the great response and solid advice! Looks like things are good now.
 * S
 *  Plugin Author [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * (@toddhalfpenny)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/adding-shortcode-to-header-php/#post-8936217)
 * Great stuff [@3cstudio](https://wordpress.org/support/users/3cstudio/), that’s
   great news.
    Oh, and if you like the plugin (and support) then a nice 5* review
   would be greatly appreciated 😉

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding shortcode to header.php’ is closed to new replies.

 * ![](https://ps.w.org/widgets-on-pages/assets/icon.svg?rev=1400727)
 * [Widgets on Pages](https://wordpress.org/plugins/widgets-on-pages/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/widgets-on-pages/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/widgets-on-pages/)
 * [Active Topics](https://wordpress.org/support/plugin/widgets-on-pages/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/widgets-on-pages/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/widgets-on-pages/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [toddhalfpenny](https://wordpress.org/support/users/toddhalfpenny/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/adding-shortcode-to-header-php/#post-8936217)
 * Status: resolved