WordPress.org

Ready to get started?Download WordPress

Forums

Add post in a catetory automaticly to a page? (2 posts)

  1. Sn3ipen
    Member
    Posted 5 years ago #

    I am totaly new to WordPress but need some answers

    Is there any way to make posts in a specific category and or child category end up in a page automaticly?

  2. tsguitar
    Member
    Posted 5 years ago #

    Do you mean that you want to write a Page that will show only posts from a certain category, like a "Writing" category page? query_posts is what you'd want to use. Give this a shot:

    <?php
    /*
    Template Name: Test
    */
    ?>
    
    <?php query_posts('category_name=yourcategoryname');
    while (have_posts()) : the_post();
      // do whatever you want
    ?>
    <a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    <?php
    endwhile;
    ?>

    Paste that into a PHP file, let's say test.php, and upload it to your theme folder. Then create a Page (don't type anything in the page itself) and select Test from the Page Template list. Visit the page and see what happens. Here's some reading:
    http://codex.wordpress.org/Pages#Page_Templates

    Is there a reason you can't just use the specific category page instead of creating a new page? It seems like you're creating a page to display something that you can already do automatically with WordPress. Let me know how I'm misunderstanding.

Topic Closed

This topic has been closed to new replies.

About this Topic