Have widgets display on a Custom Template
-
I have a simply modification to the default sidebar template of WordPress 3.5 on a client’s website http://www.stjosephmuseum.ca
The homepage uses this modified template. Cannot seem to get the widgets destined for the customized homepage to display other than “Support” which is universal.
The modified Sidebar Template’s purpose is to publish “posts” assigned to a specific category.
Here’s the code for the modified Sidebar Template:
<?php /** * Template Name: Homepage Sidebar Template * Description: A Page Template that adds a sidebar to pages * * @package WordPress * @subpackage Twenty_Eleven * @since Twenty Eleven 1.0 */ get_header(); ?> <div id="primary" style="margin: 0 -26.4% 0 0%; width: 74%; padding:0;float:left;display:inline;"> <div id="content" style="margin: 0%;" role="main"> <?php the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php /* Lets see if we have a category to display */ global $post; // Save our page posts to use later $tmp_post = $post; $catid = ""; // Do we have a category set on the custom fields $meta_cat = get_post_meta($post->ID, 'category', true); // Do we have an order set on the custom fields $asc = get_post_meta($post->ID, 'asc', true); // Do we want to display thumbnail and excerpts list? $excerpt = get_post_meta($post->ID, 'list', true); // Do not rely on what the admin entered $order = $asc ? 'ASC' : 'DESC'; if( $meta_cat ) { // If we have a meta value is it numeric or a slug, return an id $catid = is_numeric( $meta_cat ) ? $meta_cat : get_cat_ID($meta_cat); } // No category ID so use the page slug to find a category if( !$catid ) $catid = get_cat_ID($post->post_name); // If we have a category id we can get the category posts if( $catid && is_numeric( $catid ) ) { $do_not_show_stickies = 1; // 0 to show stickies $args = array( 'cat' => $catid, 'paged' => $paged, 'order' => $order, 'ignore_sticky_posts' => $do_not_show_stickies ); $wp_query= null; $wp_query = new WP_Query(); $wp_query->query( $args ); // Output our Query if ( $wp_query->have_posts() ) : twentyeleven_content_nav( 'nav-above' ); while ( $wp_query->have_posts() ) : $wp_query->the_post(); if( $excerpt ) : get_template_part( 'content', 'excerpt' ); else : get_template_part( 'content', get_post_format() ); endif; endwhile; twentyeleven_content_nav( 'nav-below'); endif; } ?> <?php // Reset the post to the page post $post = $tmp_post; ?> <?php comments_template( '', true ); ?> </div><!-- #content --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
The topic ‘Have widgets display on a Custom Template’ is closed to new replies.