Support » Fixing WordPress » Adding multiple sections to one page, with different categories – Help!

  • dannn91

    (@dannn91)


    Hi there! This is my first post here!

    I’m having a problem with my current website im working on (http://www.besidebigbrother.com/) bacically, I want to add 2 more “sections” to this website on the main page, and then have seperate pages with just these posts on them.

    I’m not very great at PHP coding, but I know my way around it if I need too.

    My current page looks like this, and I was wondering if this is possible.. So I could add a “Recaps” section and a “Housemates” section..Lets say…

    <?php get_header(); ?>
    
    <!-- ---------------------- START CONTENT ------------------------- -->
    <div id="content">
      <h4>News</h4>
        <?php query_posts('category_name=news&showposts=2'); ?>
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
            <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    		  <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    				<?php the_post_thumbnail('thumb'); ?>
    				<span class="date"><?php the_time('F jS') ?></span><?php the_excerpt(); ?>
      </div>
    
    	<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<p>I think your lost...</p>
    
    	<?php endif; ?>
    
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    I’d love it if someone could help out! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    just copy and multiply this section:

    <h4>News</h4>
        <?php query_posts('category_name=news&showposts=2'); ?>
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
            <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    		  <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    				<?php the_post_thumbnail('thumb'); ?>
    				<span class="date"><?php the_time('F jS') ?></span><?php the_excerpt(); ?>
      </div>
    
    	<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<p>I think your lost...</p>
    
    	<?php endif; ?>

    just change the title and the word ‘news’ in this line <?php query_posts('category_name=news&showposts=2'); ?> to the different categories.
    http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

    and add wp_reset_query(); after the endif; in each section.

    dannn91

    (@dannn91)

    Trying it now, thankyou so much! 🙂 I’ll let you know how it goes.

    dannn91

    (@dannn91)

    Worked great 🙂 Thankyou so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding multiple sections to one page, with different categories – Help!’ is closed to new replies.