• Resolved apsltd

    (@apsltd)


    Hi,

    I am using the Sentric theme from Imaginem. It’s nice because I can use a page template to create a blog page that has nicer styling, etc. than the default wordpress category page. The issue is the page pulls all the posts from all categories. We want to display only posts for categories related to that post.

    Below is the php file that is populating the code. Can anyone help me with this?

    Thanks!

    <?php
    /*
    Template Name: Blog Small Thumbnails
    */
    ?>
    <?php get_header(); ?>
    <?php
    global $mtheme_pagelayout_type,$mtheme_pagestyle;;
    $mtheme_pagelayout_type="two-column";
    $mtheme_pagestyle= get_post_meta($post->ID, MTHEME . '_pagestyle', true);
    $floatside="float-left";
    if ($mtheme_pagestyle=="rightsidebar") { $floatside="float-left"; }
    if ($mtheme_pagestyle=="leftsidebar") { $floatside="float-right"; }
    if ($mtheme_pagestyle=="nosidebar") { $mtheme_pagelayout_type="fullwidth"; }
    ?>
    <?php if ($mtheme_pagestyle=="nosidebar") { ?>
    	<div class="fullpage-contents-wrap">
    <?php } else { ?>
    	<div class="contents-wrap <?php echo $floatside; ?> two-column">
    <?php } ?>
    	<?php
    	if ( get_query_var('paged') ) {
    		$paged = get_query_var('paged');
    	} elseif ( get_query_var('page') ) {
    		$paged = get_query_var('page');
    	} else {
    		$paged = 1;
    	}
    	query_posts('paged='.$paged.'&posts_per_page=');
    	?>
    	<div class="entry-content-wrapper bloglist-small">
    	<?php get_template_part( 'loop', 'blog' ); ?>
    	</div>
    </div>
    <?php
    if ($mtheme_pagestyle=="rightsidebar" || $mtheme_pagestyle=="leftsidebar" ) {
    	get_sidebar();
    }
    ?>
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter apsltd

    (@apsltd)

    Update.

    I made a change to the code as follows. It seems to display the contents of the blog category and it’s children, but it is not paginating properly, as in when you click page 2 the same posts are there.

    I’m not a php master, and I’ll keep digging, but any help is appreciated.

    Thanks!

    Here is the change:

    <?php } ?>
    	<?php
    	if ( get_query_var('paged') ) {
    		$paged = get_query_var('paged');
    	} elseif ( get_query_var('page') ) {
    		$paged = get_query_var('page');
    	} else {
    		$paged = 1;
    	}
    	query_posts('category_name=aps-sailing-blog', 'paged='.$paged.'&posts_per_page=');
    	?>
    	<div class="entry-content-wrapper bloglist-small">
    	<?php get_template_part( 'loop', 'blog' ); ?>
    	</div>
    </div>
    <?php
    Thread Starter apsltd

    (@apsltd)

    Done and posting for anyone else that needs it. I had separated my arguments instead of using &.

    Works great now.

    <?php
    	if ( get_query_var('paged') ) {
    		$paged = get_query_var('paged');
    	} elseif ( get_query_var('page') ) {
    		$paged = get_query_var('page');
    	} else {
    		$paged = 1;
    	}
    	query_posts('category_name=accessories&paged='.$paged.'&posts_per_page=');
    	?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Posts from Specific Category(ies) on Page’ is closed to new replies.