• Resolved 3cstudio

    (@3cstudio)


    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

    (@toddhalfpenny)

    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

    Thread Starter 3cstudio

    (@3cstudio)

    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

    (@toddhalfpenny)

    Great stuff @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.