• Resolved digibuze

    (@digibuze)


    I need to display posts from a single category (category ID=11) on my theme’s blog template page (page-blog.php). This is the contents of that page:

    <?php
    /*
     * Template Name: Blog
    */
    get_header(); ?>
    
    			<div id="content" class="container clearfix">
    
    				<!-- page header -->
    				<div class="container clearfix ">
    
    					<?php if(of_get_option('sc_showpageheader') == '1' && get_post_meta($post->ID, 'snbpd_ph_disabled', true)!= 'on'  ) : ?>
    
    						<?php if(get_post_meta($post->ID, 'snbpd_phitemlink', true)!= '') : ?>
    
    						<?php
    
    						$thumbId = get_image_id_by_link ( get_post_meta($post->ID, 'snbpd_phitemlink', true) );
    						$thumb = wp_get_attachment_image_src($thumbId, 'page-header', false);
    						?>
    						<img class="intro-img" alt=" " src="<?php echo $thumb[0] ?>" alt="<?php the_title(); ?>"  />
    
    						<?php elseif (of_get_option('sc_pageheaderurl') !='' ): ?>
    
    							<?php
    							$thumbId = get_image_id_by_link ( of_get_option('sc_pageheaderurl') );
    							$thumb = wp_get_attachment_image_src($thumbId, 'page-header', false);
    							?>
    							<img class="intro-img" alt=" " src="<?php echo $thumb[0] ?>" alt="<?php the_title(); ?>"  />
    
    						<?php else: ?>
    
    							<img class="intro-img" alt=" " src="<?php echo get_template_directory_uri(); ?>/library/images/inner-page-bg.jpg" />
    
    						<?php endif ?>
    					<?php endif ?>
    
    				</div>
    
    				<!-- content -->
    				<div class="three-fourth">
    
    					<h1><?php the_title(); ?> <?php if ( !get_post_meta($post->ID, 'snbpd_pagedesc', true)== '') { ?>/<?php }?> <span><?php echo get_post_meta($post->ID, 'snbpd_pagedesc', true); ?></span></h1>
    
    					<div id="main" role="main">
    
    							<?php
    								// WP 3.0 PAGED BUG FIX
    								if ( get_query_var('paged') )
    								$paged = get_query_var('paged');
    								elseif ( get_query_var('page') )
    								$paged = get_query_var('page');
    								else
    								$paged = 1;
    
    								$args = array(
    								'post_type' => 'post',
    								'paged' => $paged );
    								query_posts($args);
    							?>
    
    							<?php if (have_posts()) : $count = 0; ?>
    							<?php while (have_posts()) : the_post(); $count++; global $post; ?>
    
    								<?php get_template_part( 'content', 'single' ); ?>
    
    							<?php endwhile; ?>
    
    						<!-- begin #pagination -->
    								<?php if (function_exists("wpthemess_paginate")) { wpthemess_paginate(); } ?>
    						<!-- end #pagination -->
    
    						<?php else : ?>
    
    						<article id="post-not-found">
    						    <header>
    						    	<h1><?php _e("No Posts Yet", "site5framework"); ?></h1>
    						    </header>
    						    <section class="post_content">
    						    	<p><?php _e("Sorry, What you were looking for is not here.", "site5framework"); ?></p>
    						    </section>
    						</article>
    
    						<?php endif; ?>
    
    					</div> <!-- end #main -->
    
    				</div><!-- three-fourth -->
    
    				<div class="one-fourth last">
    					<?php get_template_part( 'blog', 'sidebar' ); ?>
    				</div>
    
    			</div> <!-- end #content -->
    <?php get_footer(); ?>

    Does anyone know how to accomplish this?
    I would really appreciate help here.

    Thank you very much.
    Ben

Viewing 2 replies - 1 through 2 (of 2 total)
  • Edit this part of the file, preferably in a child theme:

    $args = array(
    'post_type' => 'post',
    'paged' => $paged );
    query_posts($args);

    to this:

    $args = array(
    'post_type' => 'post',
    'cat' => 11,
    'paged' => $paged );
    query_posts($args);
    Thread Starter digibuze

    (@digibuze)

    Thank you so much WPRanger!
    God bless you 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display posts from single category on blog page template’ is closed to new replies.