Jump to content
Sign in to follow this  
silverlakenc

Creating New Page Template

Recommended Posts

silverlakenc

I am trying to create a new template for Pages so that I can have posts from a single category show up on a page. I found a code on Wordpress.org, which says I should create a custom field on the page labeled CATEGORY. And then create a new PHP file. I did so, both in the themes folder in my manager, and in the library. I'm in whitehousepro and it doesn't seem to work, The sidebar is the only thing that shows. Is there something I have to do specifically to get it to work? Or is there another way to do so in whitehousepro? thanks! Here is the code: <?php /* Template Name: PageOfPosts */ get_header(); ?> <div id="content" class="narrowcolumn"> <?php if (is_page() ) { $category = get_post_meta($posts[0]->ID, 'category', true); } if ($category) { $cat = get_cat_ID($category); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $post_per_page = 4; // -1 shows all posts $do_not_show_stickies = 1; // 0 to show stickies $args=array( 'category__in' => array($cat), 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged, 'posts_per_page' => $post_per_page, 'caller_get_posts' => $do_not_show_stickies ); $temp = $wp_query; // assign orginal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); if( have_posts() ) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></h2> <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small> <div class="entry"> <?php the_content('Read the rest of this entry ?»'); ?> </div> <p class="postmetadata"><?php the_tags('Tags: ', ', ', ''); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments ?»', '1 Comment ?»', '% Comments ?»'); ?></p> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('?« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries ?»') ?></div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; $wp_query = $temp; //reset back to original query } // if ($category) ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>

Share this post


Link to post
Share on other sites
bryan-hadaway

This isn't necessary, there already are category pages. You can simply add them to the menu so they're like normal pages in: Appearance > Menus which I imagine is the desired effect? Thanks, Bryan

Share this post


Link to post
Share on other sites
silverlakenc

Actually, I need for one particular category to be a main page in the main menu. As opposed to a customized menu that appears as a widget. Is that possible?

Share this post


Link to post
Share on other sites
catrina

To clarify: what do you mean when you say that you want a particular category to be a "main page" in the main menu? Do you mean that you want the category to be apart of the menu where all of the regular page links are?


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
silverlakenc

Hi. What we want is for there to be a new menu item in the main, primary, top menu that runs across. Normally in WP3, I believe we could add this in the Menu admin area.... but it appears that this theme has disabled that, and that the theme is simply pulling those items, the ones on the main menu, in header.php via the function wp_list_pages()... so it's only displaying pages. Short of modifying this header.php file, is there any way to add the category we want onto the main menu? Thanks!

Share this post


Link to post
Share on other sites
catrina

There is a way to add the category you want onto the main menu by creating a custom menu (Appearance > Menus), which will display the page links and you can add the category as a custom link. Just make sure the custom menu you create is selected as the primary navigation. Have you tried this solution yet?


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×