• Hi all

    One of those annoying newbies here…

    I have made two custom pages
    page_my_homepage.php
    page_testimonial.php

    and I have registred two new sidebar names in functions.php

    /* two new sidebars  */
    
    	register_sidebar( array(
    		'name' => __( 'my homepage Sidebar', 'twentytwelve' ),
    		'id' => 'my homepage sidebar',
    		'description' => __( 'Appears on posts and pages except the my Front Page template, has its own widgets', 'child of twentytwelve' ),
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget' => '</aside>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );
    
    	register_sidebar( array(
    		'name' => __( 'testimonial page Sidebar', 'twentytwelve' ),
    		'id' => 'testimonial page sidebar',
    		'description' => __( 'Appears on testimonial page only template,  has its own widgets', 'child of twentytwelve' ),
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget' => '</aside>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );
    
    /* end two new sidebars  */

    I cannot workout how to call the sidebars into the pages as there is no reference to sidebars in the page files all they contain is this (copied from page.php

    get_header(); ?>
    
    		<div id="primary">
    			<div id="content" role="main">
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php get_template_part( 'content', 'page' ); ?>
    
    					<?php comments_template( '', true ); ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    			</div><!-- #content -->
    		</div><!-- #primary -->
    
    <?php get_footer(); ?>

    Could someone point me at what I am missing please. I am not keen to use widgets or plugins as I would prefer to learn what is happening “under the bonnet”

    Mark

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 15 replies - 1 through 15 (of 15 total)
  • Are you using a child theme?

    Thread Starter markbaigent

    (@markbaigent)

    Hi esme

    Yes I am
    Sorry I should have said so ??

    Thread Starter markbaigent

    (@markbaigent)

    shou;d have been sorry esmi…. I need coffee

    Have you created two new sidebar-xxx.php files in your child theme to match your new registered sidebars?

    Thread Starter markbaigent

    (@markbaigent)

    I am just trying to work ut how to do that at the moment

    Thread Starter markbaigent

    (@markbaigent)

    Ok I think that I have made a new sidebar file…

    myhomepage_sidebar.php
    but all that I have changed is the div id

    <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
    		<div id="my homepage sidebar" class="widget-area" role="complementary">
    			<?php dynamic_sidebar( 'sidebar-1' ); ?>
    		</div><!-- #secondary -->
    	<?php endif; ?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    myhomepage_sidebar.php

    Change that file’s name to sidebar-myhomepage.php. It can then be called in the relevant template file using <?php get_sidebar('myhomepage);?>`.

    Thread Starter markbaigent

    (@markbaigent)

    Thanks esmi

    Is it ok if I email you?

    Sorry but I only provide email support to paying clients.

    Thread Starter markbaigent

    (@markbaigent)

    It was paying work that I wanted to email you about?

    Click on my username here and it will take you to a page containing contact links. ??

    Thread Starter markbaigent

    (@markbaigent)

    > It can then be called in the relevant template
    > file using <?php get_sidebar(‘myhomepage);?>`.

    Ah, that brings me back to my question, I assumed that would be the page.php but there is no mention of the sidebar in the page.php.
    So I guess that is not the correct template?

    the standard page.php calls the header and footer but not the sidebar

    get_header(); ?>
    
    		<div id="primary">
    			<div id="content" role="main">
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php get_template_part( 'content', 'page' ); ?>
    
    					<?php comments_template( '', true ); ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    			</div><!-- #content -->
    		</div><!-- #primary -->
    
    <?php get_footer(); ?>

    Is this a child of Twenty Twelve? If you check in the parent theme, you’ll see that page.php uses get_sidebar() just before get_footer().

    Thread Starter markbaigent

    (@markbaigent)

    There is!!!……………………

    …………………………………… well so there is.

    Thanks for sticking with this you are an angel ??

    Oh, you have mail

    All the best
    Mark

    Oh, you have mail

    Yep – will get back to you asap. ??

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘custom page with custom side bar’ is closed to new replies.