• Hi all,

    I am trying to display all posts in a specific category (ID6) on a newly created page (ID7), but I am having trouble. So far I have tried to add a new WP_query to a copy of the page template underneath the the_content(); call. However that deos not work.

    Does anyone have any suggestion on how I can achieve this to maintain the ease of editing the page that this template is linked to?

    Thanks,
    Sebastian

    <?php
    /*
    Template Name: Staff
    */
    ?>
    
    <?php get_header() ?>
    
    	<div id="container">
    		<div id="content">
    
    <?php the_post() ?>
    
    			<div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>">
    				<h2 class="entry-title"><?php the_title() ?></h2>
    				<div class="entry-content">
    <?php the_content() ?>
    <!-- Display the staff posts -->
    <?php
    	$thestaff = new WP_Query();
    	$thestaff->query('category_name=Staff&showposts=-1');
    	while($thestaff->have_posts()) : $thestaff->the_post();
    ?>
    
    		<div class="thepost">
    		<h4><?php the_title(); ?></h4>
    
    		<div class="theentry">
    			<?php the_content('<br />Read complete article'); ?>
    		</div>
    	</div>
    
    <?php endwhile; ?>
    <!-- End staff posts -->
    <?php wp_link_pages('before=<div id="page-links">'.'Pages: '.'&after=</div>&next_or_number=next&nextpagelink=Next Page&previouspagelink=Earlier'); ?>
    
    <?php edit_post_link( __( 'Edit', 'sandbox' ), '<span class="edit-link">', '</span>' ) ?>
    
    				</div>
    			</div><!-- .post -->
    
    <?php if ( get_post_custom_values('comments') ) comments_template() // Add a key+value of "comments" to enable comments on this page ?>
    
    		</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php get_sidebar() ?>
    
    <?php get_footer() ?>
Viewing 1 replies (of 1 total)
  • Thread Starter sebastian_a

    (@sebastian_a)

    Since nobody replied I thought I post my solution so it may help others.


    <?php
    /*
    Template Name: Staff
    Version: 1.0
    Author: Sebastian Auer
    URL: http://neolithmedia.com

    */
    ?>

    <?php get_header() ?>

    <div id=”container”>
    <div id=”content”>

    <?php while ( have_posts() ) : the_post() ?>

    <div id=”post-<?php the_ID() ?>” class=”<?php sandbox_post_class() ?>”>
    <h2 class=”entry-title”><?php the_title() ?></h2>
    <div class=”entry-content”><?php the_content(); ?></div>
    </div>

    <?php endwhile; ?>

    <!– <h2>Meet the staff</h2> –>

    <?php query_posts(‘cat=6&orderby=title&order=ASC’);
    while (have_posts()) : the_post(); ?>
    <div class=”<?php sandbox_post_class() ?>”>
    <h3 class=”entry-title”><?php the_title(); ?></h3>
    <div class=”entry-content”><?php the_content(); ?></div>
    </div>

    <?php endwhile; ?>

    </div><!– #content –>
    </div><!– #container –>

    <?php get_sidebar() ?>
    <?php get_footer() ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying category posts on a page’ is closed to new replies.