Support » Theme: Hueman » Display Single Category in Dynamic Posts

  • 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:

    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>'; ?>
    			<?php get_template_part('inc/pagination'); ?>
    		<?php endif; ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thanks in advance for any help.

  • The topic ‘Display Single Category in Dynamic Posts’ is closed to new replies.