Home › Forums › Other › strange wordpress category problem › Re: strange wordpress category problem
January 21, 2011 at 5:55 pm
#64659
dhechler
Member
you could try querying for the news category on your news page.
Make a blank news.php page in your theme file and use this code to make it a template
/*
Template Name: News
*/
get_header();
then to query for posts in the news category, just use the query_posts function
//The Query
query_posts( 'category_name=news' );
//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
//put all of your code in here to echo a post, such as:
the_title();
endwhile; else:
endif;
//Reset Query
wp_reset_query();
//this calls the sidebar, if you dont want that, then delete this next link
get_sidebar();
//this next line calls the footer.
get_footer();
?>
So all together your code in news.php looks like this.
/*
Template Name: News
*/
get_header();
//The Query
query_posts( 'category_name=news' );
//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
//put all of your code in here to echo a post, such as:
the_title();
endwhile; else:
endif;
//Reset Query
wp_reset_query();
//this calls the sidebar, if you dont want that, then delete this next link
get_sidebar();
//this next line calls the footer.
get_footer();
?>
then go into your backend to the news page and choose “news” from your template dropdown on the right-hand side.
Hope this helps you get where you need to go.