WordPress.org

Forums

Sidebar on single.php (19 posts)

  1. JCKnoell
    Member
    Posted 2 years ago #

    So, my sidebar is working just fine on my blog page: beta.cleantelligent.com/blog
    However, when you click a single post, I'd like that same sidebar to show up.

    I am assuming this would be under single.php, right? That code is listed below. Let me know if you need any other code and I'll post it here.

    I have the 'blog' sidebar in my page attributes on the Edit Page in WordPress, but it's just not being recognized by the template, I guess?

    Any help would be great. Thanks!

    <?php
    get_header(); ?>
    <div class="blackbar">
    <div class='bbw'>
    Blog
    </div>
    </div>
    <div class='cont-wrap'>

    <div id="primary">
    <?php
    $post_obj = $wp_query->get_queried_object();
    $post_name = $post_obj->post_name;
    if($post_name == 'blog'){
    echo 'Blog';
    }else{
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
    }
    ?>
    <div id="content" role="main">

    <?php while ( have_posts() ) : the_post(); ?>

    <?php get_template_part( 'content', 'archive' ); ?>

    <?php endwhile; // end of the loop. ?>

    </div><!-- #content -->
    </div><!-- #primary -->
    <?php get_sidebar(); ?>
    </div>

  2. JCKnoell
    Member
    Posted 2 years ago #

    If it helps, there's been some additional discussion on this page:
    http://stackoverflow.com/questions/20640166/wordpress-sidebar-on-single-php

    You can see additional code there too.

  3. JCKnoell
    Member
    Posted 2 years ago #

    Has this post been buried or is everyone stumped? :)

  4. WPyogi
    Forum Moderator
    Posted 2 years ago #

  5. JCKnoell
    Member
    Posted 2 years ago #

    wow... this is a little bit out of my league... I am using a customized theme that was designed by someone else. Twenty Eleven is the parent, I believe.
    The get sidebar action is there... I get lost when it comes to the function.php

  6. JCKnoell
    Member
    Posted 2 years ago #

    I tried what the post said and it's still not working... didn't change anything anywhere on my site.

    Honestly, if you look at http://beta.cleantelligent.com/tour/work-order-software for example, the sidebar is working fine, but then on http://beta.cleantelligent.com/benefits/new-business-win-cleaning-bids which is using a direct copy of the exact same template, it's not showing anything for a sidebar... Why does this have to be so complex? Haha

  7. WPyogi
    Forum Moderator
    Posted 2 years ago #

    Twenty Eleven is the parent, I believe.

    Yep, that's why I posted that link :)

    I am using a customized theme that was designed by someone else.

    Have you asked whoever coded it? It's generally quite difficult for people here to help with highly custom themes since we don't know how they are coded.

    It actually looks like that sidebar is showing up on your single - try adding this CSS to see it:

    .left-sidebar #secondary {
      border: 1px solid red;
    }

    Have you gone through that linked article and compared what your site has to that?

  8. JCKnoell
    Member
    Posted 2 years ago #

    yeah I have... and nothing seemed to make any changes. There IS a sidebar showing up on my single posts, but it's not loading the content from the sidebar. it should look exactly like it does on the main blog page. I want the exact same sidebar.

    I tired installing an extension plugin, and it worked in bringing a sidebar to http://beta.cleantelligent.com/benefits/new-business-win-cleaning-bids but it is not style properly, but if I try to style it, it changes the style on my tour pages... sigh...

    Also, I know exactly who coded it originally and I have been called in to clean up their messes on multiple occasions. I am convinced they are the worst web design company in the nation.

  9. WPyogi
    Forum Moderator
    Posted 2 years ago #

    I have been called in to clean up their messes on multiple occasions

    Ugh. Have you validated those pages - some serious mark-up issues...not sure they're the cause of the sidebar problems but still...

  10. JCKnoell
    Member
    Posted 2 years ago #

    Yeah, I know. yes I have. the issues there are irreparable, as far as I know.

  11. WPyogi
    Forum Moderator
    Posted 2 years ago #

    I tired installing an extension plugin, and it worked in bringing a sidebar to http://beta.cleantelligent.com/benefits/new-business-win-cleaning-bids but it is not style properly, but if I try to style it, it changes the style on my tour pages... sigh...

    You should be able to target the CSS to certain pages/templates using more specific selectors? Or are there not any?

  12. JCKnoell
    Member
    Posted 2 years ago #

    I don't know... :S can you explain?

  13. WPyogi
    Forum Moderator
    Posted 2 years ago #

    The body tags have classes you can use as CSS selectors - for example that page has:

    <body class="page page-id-45 page-child parent-pageid-699 page-template page-template-t-benefits-php single-author singular two-column left-sidebar">

    So use any of those classes (that are not in the tour pages) in the CSS - this would only target this one page:

    .page-id-45 other selectors... {
       styles;
    }
  14. JCKnoell
    Member
    Posted 2 years ago #

    so, I'll be honest, I've never understood the big long classes that are in wordpress themes... I've only ever used short one-word or short phrases in my classes...

    do I just pick one of the words in there, or do I have to use the big long description?

  15. WPyogi
    Forum Moderator
    Posted 2 years ago #

    You need to use the class specific to the pages(s) you want to target. You can't use a string of classes applied to the same element (basic CSS). Start looking at the body tag output for the pages you want to target vs. the ones you don't want that CSS to apply to.

  16. JCKnoell
    Member
    Posted 2 years ago #

    Well, I fixed the benefits pages. Apparently I was missing the get sidebar call in that template after all...

    I'm still freaking out about the single post pages though...

  17. JCKnoell
    Member
    Posted 2 years ago #

    Okay, I'm finding a big discrepancy and I'm totally confused now.
    In my Tour pages (http://beta.cleantelligent.com/tour/janitorial-inspection-software for example) The template does NOT call the sidebar, nor so I have one listed in my page attributes. And yet, there it is, exactly how I want it. Where is that coming from? I cannot find that sidebar anywhere, but it's on my page.

    The benefits pages (http://beta.cleantelligent.com/benefits/new-business-win-cleaning-bids for example) and the about pages, etc are all using a custom menu right now for the sidebar, and their templates all call the sidebar.

    Where is the tour sidebar coming from? Any ideas?

    Here's the code for my tour template:

    <?php
    /**
     * Template Name: Tour
     */
    
    get_header(); ?>
    <div class="blackbar">
    <!--SOCIAL LINKS-->
    <style>
    .socialicons{ padding: 2px;}
    </style>
    <div style="top: 15px; position: absolute; left: 50%; margin-left: 353px; white-space: nowrap;">
    <a href="https://www.youtube.com/CTsoftware" target="_blank" ><img class="socialicons" height="22" width="22" src="/wp-content/uploads/2013/11/YouTubePlay.png" /></a><a href="http://www.linkedin.com/company/cleantelligent_software" target="_blank" ><img class="socialicons" height="22" width="22" src="/wp-content/uploads/2013/11/linkedin.png" /></a><a href="https://twitter.com/#!/CleanTelligent1" target="_blank" ><img class="socialicons" height="22" width="22" src="/wp-content/uploads/2013/11/twitter.png" /></a><a href="http://www.facebook.com/CleanTelligent" target="_blank" ><img class="socialicons" height="22" width="22" src="/wp-content/themes/cleantelligent/images/facebook.png" /></a><a href="https://plus.google.com/102775665167203456874" rel="publisher"><img src="/wp-content/uploads/2013/11/GooglePlusIcon.png" alt="Google +" style="padding: 0 0 1px 2px;"/></a>
    </div>
    <div style="font-family: 'News Cycle', sans-serif; color:#D1D1D1;  position: absolute; left: 50%; margin-left: 345px; white-space: nowrap; font-size: 40%;">
    <img style="position: relative; top: 8px;" src="/wp-content/uploads/2013/11/phonetrans.png" />(801) 404-5038</div>
    
    <!--END OF SOCIAL LINKS-->
    <div class='bbw'>
    <?php
    	$parent_title = get_the_title($post->post_parent);
    	echo $parent_title;
    ?>
    </div>
    </div>
    <div class='cont-wrap'>
    		<div id="primary">
    			<div id="content" role="main">
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php get_template_part( 'content', 'pricing' ); ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    			</div><!-- #content -->
    		</div><!-- #primary -->
    </div>
    
    <?php get_footer(); ?>
  18. WPyogi
    Forum Moderator
    Posted 2 years ago #

  19. JCKnoell
    Member
    Posted 2 years ago #

    This is the pricing template. It seems very simliar.

    <?php
    /**
     * Template Name: Plans and Pricing
     */
    
    get_header(); ?>
    <div class="blackbar">
    <div class='bbw'>
    <?php
    	$parent_title = get_the_title($post->post_parent);
    	echo $parent_title;
    ?>
    </div>
    </div>
    <div class='cont-wrap' style="width: 1135px;">
    		<div id="primary">
    			<div id="content" role="main">
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php get_template_part( 'content', 'pricing' ); ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    			</div><!-- #content -->
    		</div><!-- #primary -->
    </div>
    
    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic