Title: Category code pulling all blog posts
Last modified: August 20, 2016

---

# Category code pulling all blog posts

 *  Resolved [Tracypar](https://wordpress.org/support/users/tracypar/)
 * (@tracypar)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/)
 * I am using the category code, shown below, but it is pulling all posts, not just
   that category. Any thoughts?
 * [ic_add_posts category=’tips-tips’ showposts=’10’]
 * [http://wordpress.org/extend/plugins/posts-in-page/](http://wordpress.org/extend/plugins/posts-in-page/)

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/page/2/?output_format=md)

 *  Plugin Author [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3449860)
 * Howdy Tracypar,
 * Not sure what’s going on there, but I’ve a few questions for you:
    1. Is your post a custom post type or taxonomy, or is it a standard WordPress Post?
    2. Have you tried other options in the shortcode to make sure it’s working to pull
       in a specific number of posts, a different category, a tag? For instance, you
       could try a different category and see if it works and try removing the category
       =’tips-tips’ and limiting posts to: showposts=’3′ (or something similar)?
    3. Do you have a page you can point me to to see it in action?
 *  Thread Starter [Tracypar](https://wordpress.org/support/users/tracypar/)
 * (@tracypar)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450003)
 * Eric:
 * I played with this for some time, taking your advice. Nothing worked however 
   I finally realized what was going on. Where the code reads “category=’category-
   slug'” I took it to mean that I would put first the category name then dash then
   slug name. I now understand that in fact it was only the slug that was intended
   in that space.
 * I thank you for your immediate attention and assistance. And I apologise for 
   being a bit slow on the uptake!
 *  Plugin Author [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450009)
 * Glad you got this sorted, TracyPar. 🙂
 *  [jan.uetz](https://wordpress.org/support/users/januetz/)
 * (@januetz)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450024)
 * Hi!
    I’m having the same problem. Please check out the page: [http://www.trestlegroup.com/publications/](http://www.trestlegroup.com/publications/)
 * I’m using the following short code: [ic_add_posts category=’publications’ showposts
   =’2′]
    yet it’s pulling in all posts of various categories and not limiting the
   number of posts shown. Any ideas?
 * Thanks for your feedback – greatly appreciate the help.
 *  Plugin Author [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450025)
 * Hi jan.uetz,
 * A few questions to get started:
    1. What version of the plugin are you using? Make sure it’s the latest.
    2. I’m guessing your site’s set to use the default 10 posts per page under Settings/
       Reading? If you change that number, does it affect the number of posts displayed
       on your publications page? I’m guessing so.
    3. Have you tried another category to see if it works correctly?
    4. What happens if you remove the `category='publications'` from your shortcode?
 *  [jan.uetz](https://wordpress.org/support/users/januetz/)
 * (@januetz)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450026)
 * Hi Eric,
 * Thank you for your reply. I realized the problem is a different one. If the page
   is using the default page template, then the shortcode works, however, I had 
   the page set to the blog template. I like the layout of blog page better, so 
   now I just need to revamp that.
 * thanks!
 *  Plugin Author [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450027)
 * Glad you got it sorted. 🙂
 * Since the default output of the Posts in Page plugin is unstyled with minimal
   markup, you’ll notice that it doesn’t always inherit each theme’s styles.
 * If you run into that, you can look at [Changing the Output Template](http://wordpress.org/extend/plugins/posts-in-page/faq/)
   and tweaking your customize PiP output template to have the same structure and
   classes used by your theme.
 * Anyway, good on ya’ for figuring it out. Cheers!
 *  [jan.uetz](https://wordpress.org/support/users/januetz/)
 * (@januetz)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450036)
 * Hi Eric,
 * I’ve tried to further sort this out with the suggestion you made regarding changing
   the output template. While I am now getting the styling I want (from the theme),
   the plugin is now again outputting all posts and not only the ones from the category
   I’ve designated.
 * Here’s my code: [ic_add_posts template=’template-blog.php’ category=’publications’]
   
   Any idea why it won’t show only the ‘publications’ but all post categories?
 * I appreciate your help!
 *  Plugin Author [ivycat](https://wordpress.org/support/users/ivycat/)
 * (@ivycat)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450037)
 * Hey Jan,
 * Questions:
    1. Where does the `template-blog.php` file exist in your theme?
    2. Can you paste, or link to the code in your `template-blog.php` file?
    3. If you remove the `template='template-blog.php'` does it pull in the correct
       posts?
 *  [jan.uetz](https://wordpress.org/support/users/januetz/)
 * (@januetz)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450038)
 * Hi!
    thanks for your reply.
 * Here are my answers:
    1. it’s in the root folder of the theme (and it is obviously
   found by the plugin, as the design changes, but then also shows all categories
   instead of only “publications”0 2. Here’s the code:
 *     ```
       <?php
       if ( ! defined( 'ABSPATH' ) ) exit;
       /**
        * Template Name: Blog
        *
        * The blog page template displays the "blog-style" template on a sub-page.
        *
        * @package WooFramework
        * @subpackage Template
        */
   
        global $woo_options;
        get_header();
   
       /**
        * The Variables
        *
        * Setup default variables, overriding them if the "Theme Options" have been saved.
        */
   
       	$settings = array(
       					'thumb_w' => 100,
       					'thumb_h' => 100,
       					'thumb_align' => 'alignleft'
       					);
   
       	$settings = woo_get_dynamic_values( $settings );
       ?>
           <!-- #content Starts -->
           <div id="content" class="col-full">
   
               <?php woo_main_before(); ?>
   
               <section id="main" class="col-left">       
   
       		<?php woo_loop_before(); ?>
   
               <?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_args = array(
               						'post_type' => 'post',
               						'paged' => $paged
               					);
   
               	$query_args = apply_filters( 'woo_blog_template_query_args', $query_args ); // Do not remove. Used to exclude categories from displaying here.
   
               	remove_filter( 'pre_get_posts', 'woo_exclude_categories_homepage' );
   
               	query_posts( $query_args );
   
               	if ( have_posts() ) {
               		$count = 0;
               		while ( have_posts() ) { the_post(); $count++;
   
       					/* Include the Post-Format-specific template for the content.
       					 * If you want to overload this in a child theme then include a file
       					 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
       					 */
       					get_template_part( 'content', get_post_format() );
   
               		} // End WHILE Loop
   
               	} else {
               ?>
                   <article <?php post_class(); ?>>
                       <p><?php _e( 'Sorry, no posts matched your criteria.', 'woothemes' ); ?></p>
                   </article><!-- /.post -->
               <?php } // End IF Statement ?> 
   
               <?php woo_loop_after(); ?> 
   
               <?php woo_pagenav(); ?>
       		<?php wp_reset_query(); ?>                
   
               </section><!-- /#main -->
   
               <?php woo_main_after(); ?>
   
       		<?php get_sidebar(); ?>
   
           </div><!-- /#content -->    
   
       <?php get_footer(); ?>
       ```
   
 * _[Please post code or markup between backticks or use the code button. Or better
   still – use a [pastebin](http://pastebin.com/). Your posted code may now have
   been permanently damaged/corrupted by the forum’s parser.]_
 * 3. Yes, if I delete the template=’template-blog.php’ then it pulls in the correct
   category only!
 * Thanks for your help and any ideas you might have.
 *  Plugin Author [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450039)
 * Aha! Okay, I think the problems are:
    1. the template you’re trying to use to render your posts is part of your Woo theme
    2. the Woo template also has a custom query.
 * It’s a bit confusing because we’re referring to a template you use to render 
   the Posts in Page posts, but this isn’t really a traditional theme template, 
   just a file we included in the theme that you can edit, duplicate, modify, to
   affect what happens inside the Loop.
 * If you look closely at the `posts_loop_template.php` file, you’ll see that it’s
   simply the markup that appears inside the loop, not the other stuff that you’d
   normally see in a standard WordPress theme template.
 *     ```
       <!-- NOTE: if you make changes to this file, move it to your current theme's
       	directory so this file won't be overwritten when the plugin is upgraded. -->
   
       <!-- Start of Post Wrap -->
       <div class="post hentry ivycat-post">
       	<!-- This is the output of the post title -->
       	<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
   
       	<!-- This is the output of the excerpt -->
       	<div class="entry-summary">
       		<?php the_excerpt(); ?>
       	</div>
   
       	<!-- This is the output of the meta information -->
       	<div class="entry-utility">
       		<?php if ( count( get_the_category() ) ) : ?>
       			<span class="cat-links">
       				<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
       			</span>
       			<span class="meta-sep">|</span>
       		<?php endif; ?>
       		<?php
       			$tags_list = get_the_tag_list( '', ', ' );
       			if ( $tags_list ):
       		?>
       			<span class="tag-links">
       				<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
       			</span>
       			<span class="meta-sep">|</span>
       		<?php endif; ?>
       		<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
       		<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
       	</div>
       </div>
       <!-- // End of Post Wrap -->
       ```
   
 * Here’s what I’d do:
    1. copy the `posts_loop_template.php` file into your theme’s root
    2. edit the markup so it contains the classes you’re using in your Woo theme – 
       this should help your default styles ‘propagate’ to your PiP posts.
 * Note: the `posts_loop_template.php` file is a fraction of the code you pasted
   from the WooTheme. The entire _PiP_ template basically corresponds with this 
   line in your WooTheme:
 * `get_template_part( 'content', get_post_format() );`
 * I hope that helps.
    Eric
 *  [jan.uetz](https://wordpress.org/support/users/januetz/)
 * (@januetz)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450040)
 * Thank you! That took care of it – perfect! 🙂
 *  Plugin Author [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450041)
 * My pleasure. Have a great week!
 *  [justinstoner](https://wordpress.org/support/users/justinstoner/)
 * (@justinstoner)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450046)
 * I’m also having trouble with the category code.
 * See the Agriculture tab on the website here: [http://tularevoice.com](http://tularevoice.com)
 * It pulls in the post just fine, but when I apply the same code to other pages
   I don’t get the same result. I’ve tried other variations, like the tag code but
   don’t get results.
 * What am I doing wrong?
 *  Plugin Author [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/#post-3450047)
 * Hi justinstoner,
    1. What exact shortcode are you using on the pages?
    2. Are you using one shortcode on multiple pages, or is the shortcode on each page
       different?

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/page/2/?output_format=md)

The topic ‘Category code pulling all blog posts’ is closed to new replies.

 * ![](https://ps.w.org/posts-in-page/assets/icon-256x256.png?rev=1596190)
 * [Posts in Page](https://wordpress.org/plugins/posts-in-page/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-in-page/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-in-page/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-in-page/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-in-page/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-in-page/reviews/)

 * 18 replies
 * 7 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/category-code-pulling-all-blog-posts/page/2/#post-3450084)
 * Status: resolved