WordPress.org

Forums

Static Pages and Posts - Is this possible ? (3 posts)

  1. iandv
    Member
    Posted 5 years ago #

    How do I integrate certain posts/categories into a WordPress page.

    For example if I created a page on the rules of football, I would like an introduction explaining the rules of the game at the top with the relevant posts related to the football category listed below the introduction.

    Is this possible?

  2. mspecht
    Member
    Posted 5 years ago #

    Hi,

    Yes it is possible, the way I have done it is to create page template (http://codex.wordpress.org/Pages#Page_Templates) for each page that will contain a list of post for the respective category, in your example football.

    Now you need to edit the page template, a good idea to know a bit about the wordpress loop and PHP before trying this.

    The page template I created was the same as the index.php, except I called query_posts function:
    query_posts('orderby=date&posts_per_page=5&category_name=football');

    The code needs to be placed before the call:
    while (have_posts()) : the_post();

    This process creates a custom wordpress loop with just the posts from your requested category.

    One more trick if you plan to use the Excerpts function you need to also call:

    global $more;
    // set $more to 0 in order to only get the first part of the post
    $more = 0;

    before the while loop.

  3. nouveller
    Member
    Posted 5 years ago #

    You would have to create a Template Page which would have to have two loops.

    One that would pull in your normal page content, the second would need to utilise query_posts() (or possibly make a new WP_Query() object) on the second loop to pull in the football category.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.