• I’m using Ravi’s PrimePress Theme under WP 2.7.

    I have a question and greatly appreciate some answers:

    I’d like to be able to create TWO sub-sections within the main blog that users can browse to from the main page.

    I’d like these two “new” sections to contain posts that DO NOT appear in the “main” blog site… I think this can be achieved by simply selecting which “new section” the particular posts should be published in.

    Basically, MAIN BLOG >> SECTION 1 -or- SECTION 2 (the latter sections contain their own full-blog style posts, not condensed down versions).

    Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter dakrisht

    (@dakrisht)

    stiand, my apologies – I meant “Sub-pages”

    Basically, you have the MAIN PAGE and link takes you to PAGE 2, where there are full-blog style posts on page as well. However, PAGE 2 posts DO NOT appear on the MAIN PAGE.

    Same goes for PAGE 3 — it contains it’s own full-posts, which are neither on PAGE 2 or the MAIN PAGE.

    Hope this clarifies things a bit.

    Thanks.

    Ah. Shouldn’t be a problem. There are several ways to do this. The easiest would be to assign categories to the posts you want on the different Pages. Find the ID of the categories you want to use on PAGE 2 and PAGE 3. Let’s say their IDs are 5 and 7 for this example.

    Edit the home.php in your theme (if home.php doesn’t exist, duplicate index.php and rename it), find:

    <?php if (have_posts()) : ?>

    and above it put in:

    <?php query_posts('cat=-5,-7'); ?>

    Then create two template files for PAGE 2 and PAGE 3, like this (I’ll only show the template for PAGE 2, change the necessary IDs and names for PAGE 3):

    <?php
    /* Template Name: PAGE 2 */
    get_header();
    
    $page2posts = get_posts('cat=5&number_of_posts=10');
    foreach ( $page2posts as $post ):
    	setup_postdata($post);
    ?>
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    			<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    			<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    			<div class="entry">
    				<?php the_content('Read the rest of this entry &raquo;'); ?>
    			</div>
    
    			<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    		</div>
    
    <?php endforeach; ?>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    In the template for PAGE 3 you change $page2posts = get_posts('cat=5&number_of_posts=10'); to $page3posts = get_posts('cat=7&number_of_posts=10'); and rename $page2posts to $page3posts across the board.

    Change other arguments and stuff to fit your needs.

    Your frontpage/home will then show all blog posts, except from category 5 and 7. The templates you create for PAGE 2 and PAGE 3 will only show posts from category 5 and 7 respectively. Remember you have to create PAGE 2 and PAGE 3 under Pages, and assign the new templates to each of them.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Question about multiple-pages within WP’ is closed to new replies.