Title: Issues when using the_content() with query_posts()
Last modified: August 20, 2016

---

# Issues when using the_content() with query_posts()

 *  Resolved [majkelos](https://wordpress.org/support/users/majkelos/)
 * (@majkelos)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/)
 * Hi everbody,
    I’m trying to create the static page (named HOME) which would have
   some querried posts on it. When i’m executing code as this one:
 *     ```
       <?php
       	$args = array(
       		'cat'=>8,
       	);
       	query_posts($args) ?>	
   
       	<!-- while funkcja -->
       	<?php while ( have_posts() ) : the_post(); ?>
       	<!---  ----------- --->
       		<div class="sticky-header">
       			<h1><?php the_title() ?></h1>
       		</div><!-- .sticky-header -->
   
       		<div class="entry-summary">
       			the_content()
       		</div><!-- .entry-summary -->
   
       	<?php endwhile; ?>
       	<?php wp_reset_query(); ?>
       ```
   
 * I’m getting only first post from the querry (with all the titles and content)
   and after that there is a title “HOME”, as the loop is giving back name of the
   static page and nothing else.
 * On the other hand when i’m putting something like:
 *     ```
       <?php
       	$args = array(
       		'cat'=>8,
       	);
       	query_posts($args) ?>	
   
       	<!-- while funkcja -->
       	<?php while ( have_posts() ) : the_post(); ?>
       	<!---  ----------- --->
       		<div class="sticky-header">
       			<h1><?php the_title() ?></h1>
       		</div><!-- .sticky-header -->
   
       		<div class="entry-summary">								
   
       	</div><!-- .entry-summary -->
   
       	<?php endwhile; ?>
       	<?php wp_reset_query(); ?>
       ```
   
 * I’m getting all the titles as requested (without any content obviously), and 
   now not sure what is causing the problems.
 * Any ideas
 * Thank you

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/#post-3235652)
 * Try putting the_content() in php tags:
 *     ```
       <?php the_content(); ?>
       ```
   
 *  Thread Starter [majkelos](https://wordpress.org/support/users/majkelos/)
 * (@majkelos)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/#post-3235653)
 * Hi,
    thanks for your reply – it is actually like you said. But still showing 
   only one post with content, and then HOME title and nothing more
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/#post-3235654)
 * Maybe setting how many posts you want to show?
 *     ```
       $args = array(
         'cat'=> 8,
         'posts_per_page' => 10
       );
   
       query_posts($args);
       ```
   
 * Can you paste and submit the full code of the Page template into a [pastebin.com](http://pastebin.com/)
   and post the link to it here? see the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code)
   for posting code and using the pastebin.
 *  Thread Starter [majkelos](https://wordpress.org/support/users/majkelos/)
 * (@majkelos)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/#post-3235655)
 * Hi,
 * [http://pastebin.com/xYHarNQa](http://pastebin.com/xYHarNQa)
 * I really have no idea what’s going on. Here what i have attached are 2 loops 
   1st is querrying only for sticky post. –> and this one is returning only one 
   sticky post that i have published with content, and below that there is HOME.
 * Second is supposed to show all other posts, in a category (excluding sticky),
   in the version i posted there is no the_content(); in there and this option is
   showing just titles of the all posts i want.
 * But as soon as i put <?php the_content(); ?> (in line 82), in there what i get
   is the one title, one content, and below that there is an HOME title and that’s
   all.
 * I’m trying now to solve this one using get_posts() maybe this will do, but i’m
   not sure how will it end up.
 * Thank you
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/#post-3235656)
 * I’ve tested your template in the origin theme and have no problem with the_content().
 * try:
    – deactivating **all** plugins to see if this resolves the problem? If 
   this works, re-activate the plugins one by one until you find the problematic
   plugin(s).
 *  Thread Starter [majkelos](https://wordpress.org/support/users/majkelos/)
 * (@majkelos)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/#post-3235658)
 * Hi,
 * thank you for this, it was actually one of the plug-in – My Custom Widgets, where
   i had an widget with small querry on the side. After disabling this one all went
   back to normal.
 * I managed to fix original issues with this chunk of code:
 *     ```
       <?php
       $args = array( 'numberposts' => 10, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date", 'cat'=>8, 'post__in'  => get_option( 'sticky_posts' ));
       $postslist = get_posts( $args );
       foreach ($postslist as $post) : setup_postdata($post); ?>
       <div class="sticky-header">
       <?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>
       <?php get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'image_class' => 'featured' ) ); ?>
       </div>
       <div class="entry-summary">
       <p><?php the_content(); ?></p>
       </div>
       <?php endforeach; ?>
       ```
   
 * basically using get_posts() instead of query_posts()
 * keesiemeijer thank you again
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/#post-3235659)
 * No problem 🙂
    I’m glad you got it resolved.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Issues when using the_content() with query_posts()’ is closed to new 
replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [the_content](https://wordpress.org/support/topic-tag/the_content/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/issues-when-using-the_content-with-query_posts/#post-3235659)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
