• Hey, Im fairly new to WordPress and I want to know if this is possible. I have seen it discussed a few places but I have not found any solution.

    What Im wanting to do it create a few pages, for exaple the pages will be called ‘Dog’, ‘Cat’ and ‘Mouse’.
    There will be a bit of static content at the top of each page and below that I would like to display all posts from a selected category.

    So on the dog page I would write some static content saying what a dog was and then call in all the posts within the category ‘dogposts’ which will be displayed below.

    Is this possible? I know about organizing categories but I don’t want posts in the ‘dogposts’ category to be displayed on the front page, just on the dog page. I would also like to be able to insert static content before/above the posts as mentioned.

    Does anyone know if this is possible or of a hack/plugin that could accomplish this?
    Any help is much appreciated.
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • For each page, create a template, with the static text you want, the query for the category you want to display, and a copy of index.php of your theme.

    For example for the Dog page

    <?php /*
    	Template Name: Dog
    */ ?>
    
    <?php get_header(); ?>
    
    	<div id="check you theme layout" class="check your theme">
    
    <p>Here you can write anything about dogs that will be displayed statically on the page...</p></div>	
    
    		<?php if(have_posts()) : ?>
    		<?php
       if (is_page()) {
          query_posts("cat=3");
       }
    ?>
    
    		<?php while(have_posts()) : the_post(); ?>
    
    Here you continue with the rest of the index template, to include post permalinks, sidebar, footer, etc.

    Then you create a new page and call it Dog, and from the attributes, you select “Dog” as your template for that page.

    Remember to put in the query the correct number for the category to display, it’s 3 in the example.

    Publish the page. Now you will have a “Dog” page with text and that category pulled in the loop query. Repeat the process for the Cat and Mouse pages.

    Hope this is clear enough.

    Thread Starter drinkingsouls

    (@drinkingsouls)

    Hey, thanks for the help. I understood what you meant but I’m having a problem doing it.
    I have the template file video.php in my template directory and I set a page to use it. This is the code from the template file:

    <?php
    /*
    Template Name: Video
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content">
    
    <div class="post">
    
    		<?php if(have_posts()) : ?>
    		<?php
       if (is_page()) {
          query_posts("cat=3");
       }
    ?>
    
    		<?php while(have_posts()) : the_post(); ?>
    
    </div>
    
    </div>
    
    <?php
    get_sidebar();
    get_footer();
    ?>

    But when I view the page it shows nothing. If I take out the php it shows a blank layout without content, but with the php it shows nothing.\
    Whats causing this?
    Thanks

    In your template you left cat=3, as in my example. Is this the same as your video category? You have to query the correct number, or the posts won’t show.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Creating a static page that displays posts’ is closed to new replies.