WordPress.org

Forums

[resolved] WordPress Templates and Sidebars not working (24 posts)

  1. JCKnoell
    Member
    Posted 1 year ago #

    I have started over on designing my website's blog.
    beta.cleantelligent.com/blog
    I am trying to use a custom template (t-blog.php) to design the page. It will also need a custom sidebar in order to list archives, etc.
    This is different from my main website.

    I can't seem to get the blog template, or the blog sidebar to work. Nor is it displaying my posts. I have changed the settings in Reading so that "Blog" is my posts page.

    Any idea why it's not working at all? (The title of the page seems to be calling my most recent posts title, but the blog post itself is not there.)

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    I am trying to use a custom template (t-blog.php) to design the page.

    What page?

  3. JCKnoell
    Member
    Posted 1 year ago #

    beta.cleantelligent.com/blog

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    A static front page or your site's main posts page?.

  5. JCKnoell
    Member
    Posted 1 year ago #

    the main posts page. the static site is the home page. I'm trying to design the blog based on a custom template. It is set up in the settings as my posts page.

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    The main posts page on any WP site will always use the index.php template file automatically - irrespective of any page template that you try to apply via the back end. So you need to work on that template file - not a custom one.

  7. JCKnoell
    Member
    Posted 1 year ago #

    I'm sorry, I am a little bit confused. Isn't the index.php used by the main static page, then the page.php is used by the posts page? That's how I always thought it was. Am I backward?

  8. JCKnoell
    Member
    Posted 1 year ago #

    And wouldn't it override anyway if I change the template in the Page Attributes options?
    All of my other pages are organized into categories and I've assigned them a template and sidebar using the page attributes. (See the Tour items in the main nav. They're all atyled the same way.)
    Wouldn't I do the same with my blog? I'd like to use the same template on the blog as well as some secondary blog related pages, such as webinars, etc.

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    And wouldn't it override anyway if I change the template in the Page Attributes options?

    Nope. By design, the main posts page always uses the index.php template file. Any custom template in the Page template dropdown is simply ignored. Is there any reason why you can't edit index.php instead?

  10. JCKnoell
    Member
    Posted 1 year ago #

    Sure I can, but I just don't understand what you mean... If it always uses index.php, then what's the point of the custom templates? Or is that only for static pages?

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    Or is that only for static pages?

    Pretty much, yes. The main posts page is a special case.

  12. JCKnoell
    Member
    Posted 1 year ago #

    Well okay then. That was never made clear before. Thanks Esmi. You've always seemed to be a huge help on this forum. I always hope it will be you who answers my questions. :)

  13. JCKnoell
    Member
    Posted 1 year ago #

    So, is that the "default template"?

  14. JCKnoell
    Member
    Posted 1 year ago #

    I answered that myself. It seems to be working now. Thanks a load!

  15. esmi
    Forum Moderator
    Posted 1 year ago #

    No problem. You might want to bookmark the Template_Hierarchy page to try and avoid this kind of frustration in future. :-)

  16. JCKnoell
    Member
    Posted 1 year ago #

    Esmi,

    If you're still around for answers, I have a related question. So, the blog is recognizing my posts now, but the sidebar is gone, as well as the option in page attributes for the sidebar.

    I have <?php get_sidebar(); ?> in my index.php, but the option isn't there in the blog edit page... How do I load one of my WP sidebar widgets onto this blog page?

  17. esmi
    Forum Moderator
    Posted 1 year ago #

    Is this in your theme's index.php template file?

  18. JCKnoell
    Member
    Posted 1 year ago #

    yes.

  19. esmi
    Forum Moderator
    Posted 1 year ago #

    Did you create this theme or was it downloaded from somewhere?

  20. JCKnoell
    Member
    Posted 1 year ago #

    The theme was created by a third-party web design company, (which company is among the worst I've ever dealt with) and I was called in to fix their mistakes...

  21. esmi
    Forum Moderator
    Posted 1 year ago #

    You have my sympathy...

    Have you tried turning debug on and enabling error logging to see if that helps?

  22. JCKnoell
    Member
    Posted 1 year ago #

    hmm... even after reading those articles, I probably wouldn't know what you're talking about... ;)

  23. JCKnoell
    Member
    Posted 1 year ago #

    Maybe this will help. This is the code for sidebar-web.php. I think it's broken, but I don't know exactly what I'm looking at, as php is not my thing:

    <?php
    /**
     * The Sidebar containing the main widget area.
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    
    $options = twentyeleven_get_theme_options();
    $current_layout = $options['theme_layout'];
    $nav = sb_get_page_nav($post);
    if ( 'content' != $current_layout ) :
    ?>
    <img class="sidebar-top" src='<?php bloginfo('stylesheet_directory'); ?>/images/sidebar-top.png' />
    		<div id="secondary" class="widget-area" role="complementary">
    		<?php
    			$post_obj = $wp_query->get_queried_object();
    			$post_name = $post_obj->post_name;
    			$title = 'cs-' . $post_name;
    			?>
    		<?php
    			if($post_name == 'blog'){
    				if ( ! dynamic_sidebar( 'sidebar-web' ) ) :
    				endif;
    			}
    		?>
    
    			<div class="SimpleSideNav">
    				<?php wp_nav_menu(array('container_id' => 'left-navigation','menu' => 'Support')); ?>
    			</div>
    
    		<?php if ( ! dynamic_sidebar( 'sidebar-all' ) ) : ?>
    		<?php endif; // end sidebar widget area ?>
    		<?php /*
    		<nav id="left-nav">
    			<div class="nav-wrapper">
    				<?php if(!$nav['no_nav']) {
    					wp_nav_menu(array('container_id' => 'left-navigation','menu' => $nav['title']));
    				} ?>
    			</div>
    		</nav>
    			*/ ?>
    
    			<?php if ( ! dynamic_sidebar( $title ) ) : ?>
    			<?php endif; // end sidebar widget area ?>
    			<img class="sidebar-bot" src='<?php bloginfo('stylesheet_directory'); ?>/images/sidebar-bot.png' />
    		</div><!-- #secondary .widget-area -->
    
    <?php endif;
    $parent_title = get_the_title($post->post_parent);
    if($parent_title == 'Tour'){
    	echo"
    	<script>
    	jQuery('.w-1').hide();
    	</script>
    	";
    }
    
    ?>
  24. JCKnoell
    Member
    Posted 1 year ago #

    AGH! Okay, so I finally got the blog sidebar working. beta.cleantelligent.com/blog
    However, for the single posts, if you click on one blog post, the sidebar is missing still.
    If I remember correctly, this should be single.php, right?

    Here's my code from that template... Any thoughts on why the sidebar isn't showing up on just the single posts?

    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    
     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>
    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic