Trouble displaying sidebar advertisement on every page (6 posts)

  1. evsecrets
    Posted 4 years ago #

    Hi folks,

    After searching first, I couldn't find any other posts here about this seemingly simple problem.

    On my new site news.tourslovakia.net I have three advertisements which repeat on the right hand sidebar, linking to the product we're offering.
    I placed those three sidebar adverts using the Appearance>Widgets>Text option in the menu. The point & drag widget thingy made life quite easy.

    However, when you click on an individual story, the page doesn't show any sidebar advertising at all.

    Ideally, I'd like one of those long sidebar ads displayed on every page the reader goes to. I've tried pasting different things into different places in the Appearance>Editor>Sidebar.PHP page but the banner ad ends up in the most bizarre places; normally at the bottom of the page!

    I'm running the standard "Twenty eleven 1.2" theme which is nice and clean.

    Any help (in non geek-speak) would be greatly appreciated.


  2. Michael
    Forum Moderator
    Posted 4 years ago #

    the sidebar behavour is so by design in Twenty Eleven.

    please don't edit the default theme Twenty Eleven directly - it is important to have an unedited default theme in case of serious problems.
    please create a child theme to make the edits there: http://codex.wordpress.org/Child_Themes

    when your child theme is in place, there is a solution available to have sidebars in single posts.

  3. evsecrets
    Posted 4 years ago #

    Ok, we're getting somewhere. Thanks very much for you help.

    I've created a Child Theme file in it's own folder within my website, and filled in all the details as per the instruction page, however I'm not certain how to make the sidebar advertisement show up.

    If it helps, the sidebar advert (jpg file) is located here.

    According to another WordPress help page, I think the code is
    <?php include ('sidebar2.php'); ?>
    However I'm not certain if this is correct, and more importantly, even if it is the right code to use, I have no idea where to insert this line into the child page.

    Is anyone able to tell me where to put this line (if it's correct)?

  4. Michael
    Forum Moderator
    Posted 4 years ago #

    activate the child theme;

    if you want the same sidebar to show in single posts as on the front page, edit single.php (copy single.php from Twenty Eleven into the child theme folder) and add the <?php get_sidebar(); ?> code before the 'get_footer' line.

    then edit functions.php of the child theme (if it does not yet exist, create an empty functions.php file in the child theme) and add this code:
    (if you have a new, empty functions.php, you need to add <?php first to the start - make sure there is no other character before that)

    add_filter('body_class', 'adjust_singular_body_class', 20, 2);
    function adjust_singular_body_class($wp_classes) {
    if( is_single() ) :
    // Filter the body classes
          foreach($wp_classes as $key => $value) {
          if ($value == 'singular') unset($wp_classes[$key]);
    return $wp_classes;
  5. evsecrets
    Posted 4 years ago #

    Ok, will try that now. Thank you very much.

  6. evsecrets
    Posted 4 years ago #

    Mr Alchymyth, I love you, and I think I want your babies.

    (It works, thank you very very very much)

    Three nights of toil have been solved in 2 minutes thanks to your help. There's a bucketload of good karma heading your way I'm certain. :)


Topic Closed

This topic has been closed to new replies.

About this Topic