Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1087944

    OriginalEating
    Participant

    On our site, I would like to display a blurb after every article, but “inside” the same container as the article. For example, on the page linked along with login details below, we want this to show up just under the nutrition label but inside the white box.

    My first guess was to add a widget area, and I tried to do this following the instructions in this post:

    https://community.theme.co/forums/topic/adding-new-widget-area-to-child-theme/

    However, the widget area shows up on the dashboard but not the site.

    First off, is a widget area the best way to go here? Second, is there a better way to add this nowadays?

    #1087950

    OriginalEating
    Participant
    This reply has been marked as private.
    #1088224

    Rue Nel
    Moderator

    Hello There,

    Thanks for posting in and the very detailed information. My question is what should be inside a blurb? Is it just a static text? If that is the case, since you already have your child theme active and ready, please insert this following code in your child theme’s functions.php file;

    function add_my_blurb($content){
      $blurb = "<div class="clear"></div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer scelerisque eros eu pulvinar dictum. Nunc egestas massa at elit bibendum, cursus fringilla nunc faucibus.</p>";
    
      $content = $content . $blurb;
      
      return $content;
    }
    add_filter('the_content', 'add_my_blurb');

    Hope this helps. Please let us know how it goes.

    #1088916

    OriginalEating
    Participant

    This would likely be an image – my preference would be something that my wife could edit through the wordpress dashboard, but if this is the best way I can make it work.

    #1089530

    Friech
    Moderator

    Hi There,

    In that case please update the given code to this:

    function add_my_blurb() {
     if ( is_active_sidebar( 'YOUR SIDEBAR ID' ) ) : ?>
      <div class="my_blurb">
        <?php dynamic_sidebar( 'YOUR SIDEBAR ID' ); ?>
      </div>
    <?php endif;
    }
    add_action( 'x_before_the_content_end', 'add_my_blurb' );

    Then on your admin dashboard navigate to Appearance > Sidebars create a new sidebar and copy the newly created sidebar ID and replace the YOUR SIDEBAR ID phrase on the code with it.

    Then navigate to Appearance > Widgets you will see your sidebar there for you to add a content.

    Hope it helps, Cheers!

    #1090017

    OriginalEating
    Participant

    This worked, but it’s showing the widget twice (I’m just using a tag cloud for testing):

    http://www.originaleating.com/paleo-diet-recipes/tropical-salsa-salmon/

    #1090087

    OriginalEating
    Participant

    Nevermind, found that I accidentally saved the widget twice.

    Thanks again for the great support!

    #1090341

    Rad
    Moderator

    You’re so much welcome!