WordPress.org

Forums

Hueman
Display Single Category in Dynamic Posts (1 post)

  1. Nix04
    Member
    Posted 12 months ago #

    I'm currently trying to create a template which will be used by a static page to display the normal dynamic content of the site but only for a single category.

    All I essentially wish to do is have a page identical to the default index/page but which only displays categories of my choosing rather than the entire site.

    For example, on my site I have moved the posts page to 'Blog' and created a static page named 'Travel' under the 'Home' tab.

    Under the 'Travel' page (Home), I wish to have a layout identical to the default blog, but only displaying posts from the category 'Travel' rather than a catch-all.

    I was using this template code, but it wasn't displaying the dynamic widget on the Travel page, nor was the layout correct. At the moment the page is using a default template:

    <?php
    /*
    Template Name: Travel
    */
    
    get_header(); ?>
    
    <section class="content">
    
    	<?php get_template_part('inc/page-title'); ?>
    
    	<div class="pad group">
    
    		<?php get_template_part('inc/featured'); ?>
    
    <?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?>
    
    		<?php if ( have_posts() ) : ?>
    
    			<div class="post-list group">
    				<?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?>
    				<?php get_template_part('content'); ?>
    				<?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
    			</div><!--/.post-list-->
    
    			<?php get_template_part('inc/pagination'); ?>
    
    		<?php endif; ?>
    
    	</div><!--/.pad-->
    
    </section><!--/.content-->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Thanks in advance for any help.

Reply

You must log in to post.

About this Theme

About this Topic