Blog page with a single category
-
My goal is to create 2 different blog pages, each one gets the posts from a single catogory. I’ve wandered around the forum but haven’t found the solution.
This is how my page-blog.php looks like:
<?php /* Template Name: Blog with Single Category */ ?> <?php get_header() ?> <div class="clear40"></div> <!--side bar title and bread crumb--> <div class="center-clear"> <div id="breadcrumb" class="page-columns-head-style gray-frame page-column2"> <?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?> </div> <div class="page-columns-head-style gray-frame page-column1 margin-left-10"> <h1 class="heading h1"><?php _e('Categories','th_incorporate') ?></h1> </div> </div> <!--/side bar title and bread crumb--> <!--page content wrapper--> <div id="page-content-wrapper"> <!--content container--> <div class="center-clear page-content-wrapper"> <!--page content goes here--> <div class="page-content gray-frame nopadding blog-content"> <div class="clear10"></div> <?php //global $post; global $more; // Declare global $more (before the loop). $args = array( 'meta_query' => array( array('key' => 'incorporate_post_type', 'value' => '4columngallery', 'compare' => '!='), array('key' => 'incorporate_post_type', 'value' => 'news', 'compare' => '!='), array('key' => 'incorporate_post_type', 'value' => 'special', 'compare' => '!=') ), 'post_type' => array('post'), 'showposts' => get_option('posts_per_page'), 'paged' => $paged ); //$myposts = get_posts( $args ); global $wp_query; $myposts = query_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); $more = 0; ?> <!--post--> <div class="post-box"> <!--date box--> <div class="date-box alignleft_block"> <div> <div></div> <span class="line1"><?php the_time('d')?></span> <span class="line2"><?php the_time('M')?></span> <span class="line3"><?php the_time('Y')?></span> </div> </div> <!--/date box--> <!--title--> <h1 class="alignleft_block margin-left-20 heading post-title"><?php the_title(); ?></h1> <!--/title--> <!--post content--> <div class="alignleft_block post-content margin-left-20"> <?php the_content(''); ?> </div> <!--/post content--> <div class="clear10"></div> <!--read more--> <a>" class="alignright_block button"><?php _e('READ MORE','th_incorporate')?></a> <!--/read more--> <div class="clear20"></div> <!--information bar--> <div class="info-bar alignleft_block"> <span class="posted-by"><?php _e('Posted by ','th_incorporate'); the_author_posts_link(); ?></span> <span class="tags"><?php _e('Tags : ','th_incorporate'); the_tags('',', '); ?></span> <span class="comments notextdecoration gray-only"><?php comments_number( __('No Comment','th_incorporate'), __('One Comment','th_incorporate'), '(%) '.__('Comments','the_incorporate') ); ?></span> <div class="social"> <!--add this--> <div class="addthis_toolbox addthis_default_style" addthis:url="<?php the_permalink() ?>" addthis:title="<?php the_title() ?>" addthis:description=""> <a></a> <a></a> <a></a> <a></a> <a></a> </div> <!--/add this--> </div> </div> <!--/information bar--> </div> <!--/post--> <div class="clear10"></div> <?php endforeach; ?> <!--pagination--> <?php get_pagination('<div class="paging-wrapper blog gray-frame">','</div>'); ?> <!--/pagination--> </div> <!--/page content goes here--> <?php get_sidebar('blog'); ?> </div> <!-- /content container--> <div class="clear40"></div> </div> <!--/page content wrapper--> <?php get_footer() ?>
Pretty long, isn’t it?
And just to know, I don’t want to add category straight to the menu, I just want to use Blog.
[No bumping. If it’s that urgent, consider hiring someone.]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Blog page with a single category’ is closed to new replies.