I am beginner in wordpress, I want to assign my categories that contain multiple posts to particulate page.
So please, anybody guide me?
I am beginner in wordpress, I want to assign my categories that contain multiple posts to particulate page.
So please, anybody guide me?
You can create a page template (for service page) and then set it to particular page, on which you want to display posts.
After that open page template and paste below code where you wan to show posts.
<?php
query_posts('cat=1'); // cat=1 , id of category you want to show (e.g. cat id of food category )
while (have_posts()) : the_post(); // loop for posts with category id = 1
the_content(); // print content of all founded posts
endwhile; // end loop.
?>
query_posts
is a really bad function to use as it breaks the main query, rerun queries, is slow and totally stuffs up pagination and the globals like $post
and $wp_query
. It fact, query_posts
breaks a lot of functionality. Never ever use it.
Commented
Jan 12, 2015 at 8:22