SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist bradical1379's Avatar
    Join Date
    Feb 2007
    Posts
    443
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    question about wordpress

    is there a way I can have posts from certain categories only show up on certain pages?

    So I have the categories:
    News
    Events
    Reports
    People

    And I want those to only show up on their respective pages, news, events, reports, people. So basically I am trying to categorize my posts in association to the various pages I have made.

    Possible at all?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,229
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    Categories

    When a link under "Categories" is clicked, a page with the posts in that category is displayed. If I understand you, you want to have these pages as static pages instead?

  3. #3
    SitePoint Evangelist bradical1379's Avatar
    Join Date
    Feb 2007
    Posts
    443
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically I want a page named "Events" that would just display all entries from the category "events".

  4. #4
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bradical1379 View Post
    Basically I want a page named "Events" that would just display all entries from the category "events".
    How do you envision this page being different from the archive that already exists for this category?

  5. #5
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I am understanding the question right, you would just need to create a new page in your template folder and name it after the ID of the events category. If you click on a link for a specific category, you already get the content for that category only. It's just if you want to style it specifically, you can by creating a new catgory ID page.

    So, category-10.php, for example if the ID for events is 10.

    You could also create a new single page for when you view individual posts. First thing would be to duplicate the single.php file and call it "singleOriginal.php" or something like that. Then, in the original single.php file, add the following:

    Code PHP:
    <?php
    $post = $wp_query->post;
    if ( in_category('10') ) {
    include(TEMPLATEPATH . 'single-cat-10.php');
    } else {
    include(TEMPLATEPATH . 'singleOriginal.php');
    }
    ?>

    You would now need to create a new page called "single-cat-10.php", to style it for all single posts in that category.

    Also, on an any page, you can specify in the loop that you want to only grab posts from a specific category. Just add another line called "query_posts" after the first line of the loop:

    Code PHP:
    <?php if (have_posts()) : ?>
    <?php query_posts('cat=10'); ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •