wordpress - How to make a blog page only display certain posts -
i have page in wordpress blog page template. issue displays posts. want display posts assigned category
how do that?
here blog.php page: guess have edit here right?
<?php /* template name: blog page */ ?> <?php get_header(); ?> <div class="blog"> <?php $gogo_select_blog_sidebar_position = get_post_meta($post->id, 'gogo_select_blog_sidebar_position', true); $gogo_blog_link_text = get_post_meta($post->id, 'gogo_blog_link_text', true); $gogo_blog_link_url = get_post_meta($post->id, 'gogo_blog_link_url', true); $gogo_blog_text_no_posts = get_post_meta($post->id, 'gogo_blog_text_no_posts', true); ?> <header class="box-headline"> <h4 class="main-headline"><?php the_title(); ?></h4> </header> <?php if($gogo_select_blog_sidebar_position=='right-sidebar-blog-template') { ?> <!--left content area--> <div class="blog-holder"> <?php } else { ?> <div class="blog-holder right"> <?php } ?> <?php $temp = $wp_query; $wp_query= null; $wp_query = new wp_query(); $wp_query->query('posts_per_page='.$gogo_blog_text_no_posts.'&paged='.$paged); $postcount = 0; while ($wp_query->have_posts()) : $wp_query->the_post(); $postcount++; ?> <!--begin post content--> <?php // next determines post format , shows right file accordingly $format = get_post_format(); get_template_part( '/lib/includes/post-formats/'.$format ); if($format == '') get_template_part( '/lib/includes/post-formats/standard' ); ?> <?php if($postcount % 2 == 0) echo "<div class='clearfix'></div>"; ?> <!--end post content--> <?php endwhile; ?> <!--pagination --> <?php if (function_exists("pagination")) {pagination();} ?> <!--end pagination --> <?php $wp_query = null; $wp_query = $temp;?> </div> <!--end left content area--> <?php if($gogo_select_blog_sidebar_position=='right-sidebar-blog-template') { ?> <!-- right content --> <aside class="sidebar right"> <?php } else { ?> <aside class="sidebar left"> <?php } ?> <?php get_sidebar('blog'); ?> </aside> <!-- end right content --> </div><!-- end .block --> <?php get_footer();?>
add category wp_query string:
$wp_query->query('posts_per_page='.$gogo_blog_text_no_posts.'&paged='.$paged . '&category_name=***yourcategory***');
wordpress
No comments:
Post a Comment