• Resolved diana_levy

    (@diana_levy)


    In my nirvana theme im having this issue.
    My main layout is set to one column and responsive, which works perfect! But in my page for technology blog I`ve set the layout to be two columns, sidebar on the right.
    I have also set the widget right sidebar to show recent posts, search and archives, but what I see rendering the page is still loading the main template, with no sidebars!
    I see that in the google chrome console:
    <section id=”container” class=”one-column”> But the template for right side bar must be
    <section id=”container” class=”two-columns-right”>

    My site is https://www.gb-advisors.com/es/category/tech-blog/

    Please somebody who can help me will be very appreciated, cause i love the theme but I really need to fix this issue

Viewing 4 replies - 1 through 4 (of 4 total)
  • How did you set the two columns layout? On which page did you use a page template? Which is that page’s address?

    The general layout options applies to the entire site (categories, posts, pages, so on) except individual pages using a different page layout template.

    Thread Starter diana_levy

    (@diana_levy)

    @ZedCryout Thanks for answer…
    Im checking on your answer and what I can see is that the page for technlogy blog https://www.gb-advisors.com/es/category/tech-blog/ is rendering by category, which I think is causing the template not loading the sidebar.

    In my page attributes I set that page “technology blog” this way:
    Parent: About GB
    Template: Two columns, sidebar on the right
    order: 0

    Also my permalink structure shows me: Permalink: https://www.gb-advisors.com/about/technology-blog/ ?

    In my menu I see the structure is under Category (Now I know why is showing under the category page) Now the question is how to do the category shows with the sidebar?
    Do I need to set page instead of category and create a page-template for query the technology blog?
    Better to do that with a child theme?
    What will be your recommendation?
    Thanks in advanced!

    Thread Starter diana_levy

    (@diana_levy)

    I did get that to work by making a child theme and choosing the template i’ve created as this:
    page-blog.php which has a query for my blog categories. So I had assigned the template just for that page…@ZedCryout Thanks a lot, your answer makes me to moved in that direction

    Next question is how can I achieve to the single.php shows sidebar.
    I want to show all the posts as a blog, I mean with the right sidebar too, but again the problem is what you said above:

    The general layout options applies to the entire site (categories, posts, pages, so on) except individual pages using a different page layout template.

    I think I can use a filter in my child functions to tell wordpress that dont apply the general layout for the posts template…can you help me with this please?

    Thread Starter diana_levy

    (@diana_levy)

    I answer myself in order to help anyone else trying to achieve that kind of results.

    First I’ve created a child theme…change the page which was showing the category for a page template I’ve created
    In my case my page template was page-blog.php with this structure:

    <?php /*
     * Template Name: Blog dos columnas
     *
    
     */
    get_header(); ?>
    
    		<section id="container" class="two-columns-right">
    
    			<div id="content" role="main">
    
    				<?php get_template_part( 'content/content', 'blog'); ?>
    
    			</div><!-- #content -->
    			<?php get_sidebar('right'); ?>
    		</section><!-- #container -->
    
    <?php get_footer(); ?>

    Then another file under the folder: content.
    This file has the query of my category, in my case i named it content-blog.php

    <?php
    /**
     *
     * Learn more: https://codex.www.ads-software.com/Post_Formats
     *
     * @package Cryout Creations
     * @subpackage Nirvana
     */
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
     $args = array(
        'category_name' =>'tech-blog',
    	'order' => DESC,
    	'post_per_page' => 6,
    	'paged' => $paged
    );
    query_posts($args);
    
    if ( have_posts()  ) while ( have_posts() ) : the_post(); ?>
    
    				<div id="post-<?php the_ID(); ?>" class="page-blog">
                    	<div class="imagen-blog"><?php the_post_thumbnail('blog'); ?></div>
    					<?php if ( is_front_page() ) { ?>
    						<h2 class="entry-title"><?php the_title(); ?></h2>
    					<?php } else { ?>
    						<h1 class="entry-title"><?php the_title(); ?></h1>
    					<?php } ?>
    
    					<div class="entry-content">
    
                        <div class="meta">
                        <p><?php the_date(); ?>&nbsp;-&nbsp;  <?php the_author(); ?></p>
                        </div>
                        <div class="clear"></div>
    
    					<div class="separator-blog">	
    
    					<?php the_excerpt(); ?></div>
    						<div style="clear:both;"></div>
    						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'nirvana' ), 'after' => '</div>' ) ); ?>
    						<?php edit_post_link( __( 'Edit', 'nirvana' ), '<span class="edit-link"><i class="icon-edit"></i> ', '</span>' ); ?>
    					</div><!-- .entry-content -->
    				</div><!-- #post-## -->
    
    				<?php  comments_template( '', true );
    				endwhile; ?>
    
    				<?php if($nirvana_pagination=="Enable") nirvana_pagination($the_query->max_num_pages); else nirvana_content_nav( 'nav-below' );
    
    			 ?>

    And finally to show the single page with the sidebar too what i did was altering my functions.php to this:

    add_action('template_include', 'load_single_template');
      function load_single_template($template) {
        $new_template = '';
    
        // single post template
        if( is_single() ) {
          global $post;
    
          if( has_term('tech-blog', 'category', $post) ) {
            // use template file single-template-cat-1.php
            $new_template = locate_template(array('single-template-cat-1.php' ));
          }
    
        }
        return ('' != $new_template) ? $new_template : $template;
      }

    And created a file named: single-template-cat-1.php which has the sidebar in it!
    Done…working perfect

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘sidebar in selecting page template not working’ is closed to new replies.