Support » Fixing WordPress » Add post in a catetory automaticly to a page?

  • 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?

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘Add post in a catetory automaticly to a page?’ is closed to new replies.