WordPress.org

Ready to get started?Download WordPress

Forums

Where to put code in a Page Template to fetch Category Posts (3 posts)

  1. Warruz
    Member
    Posted 6 months ago #

    Im trying to create a new Page Template (first one) that displays the posts from a specific category(not full posts, just excerpts).

    Now I have been looking at Page Template Codex on what code to us, just since i'm new to this, what part of it do I have to adjust to fit my theme?

    So far I have copied my page.php and I am wondering where I put the code to fetch the category, here is my Theme page so far(All i have done is change the name at the top and touched nothing else)

    /*
    Template Name: Podcast Main
    */
    get_header(); ?>
    
    	<?php
    	global $wp_query;
    	$postid = $wp_query->post->ID;
    	if ( get_post_meta( $postid, 'post_featpages', true ) == "Yes" ) { ?>
    		<?php include (TEMPLATEPATH . '/featured-pages.php'); ?>
    	<?php } ?>
    
    	<div id="page" class="clearfix">
    
    		<div class="page-border clearfix">
    
    		<div id="contentleft">
    
    			<div id="content" class="clearfix">
    
    				<?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } ?>
    
    				<?php include (TEMPLATEPATH . '/banner468.php'); ?>	
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    				<div class="post clearfix" id="post-main-<?php the_ID(); ?>">
    
    					<div class="entry">
    
    						<h1 class="page-title"><?php the_title(); ?></h1>
    
    						<?php if ( get_post_meta( $post->ID, 'video_embed', true ) ) { ?>
    							<div class="single-video">
    								<?php echo get_post_meta( $post->ID, 'video_embed', true ); ?>
    							</div>
    						<?php } ?>
    
    						<?php the_content(); ?>
    
    						<div style="clear:both;"></div>
    
    						<?php wp_link_pages(); ?>
    
    					</div>
    
    				</div>
    
    <?php endwhile; endif; ?>
    
    			</div>
    
    			<?php include (TEMPLATEPATH . '/sidebar-narrow.php'); ?>
    
            </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Thanks for your help

  2. esmi
    Forum Moderator
    Posted 6 months ago #

    Have you reviewed a page of posts?

  3. Warruz
    Member
    Posted 6 months ago #

    Yeah, im just new to this all so its a bit daunting. Trying to figure out what needs to replaced to reference the right things in my theme.

    Something that did work was i simply added

    <div id="primary" class="content-area">
          <?php query_posts("cat=5");

    Right after the header, this managed to display the ENTIRE posts but i need excerpts.

Reply

You must log in to post.

About this Topic