title: Wordpress query_posts
body: <p>I have problem with Wordpress custom page. I want to show news from concrete category.</p>
  
  <pre><code>&lt;?php
  /**
   * Template Name: Tutorials
   *
   * A custom page template without sidebar.
   *
   * The "Template Name:" bit above allows this to be selectable
   * from a dropdown menu on the edit page screen.
   *
   * @package WordPress
   * @subpackage Twenty_Ten
   * @since Twenty Ten 1.0
   */
  
  get_header("custom"); ?&gt;
  
          &lt;div id="container"&gt;
              &lt;div id="content" role="main"&gt;
              &lt;?php query_posts("cat=4,5,6"); ?&gt;
              &lt;?php
              /* Run the loop to output the posts.
               * If you want to overload this in a child theme then include a file
               * called loop-index.php and that will be used instead.
               */
               get_template_part( 'loop', 'index' );
              ?&gt;
              &lt;/div&gt;&lt;!-- #content --&gt;
               &lt;?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?&gt;  
          &lt;/div&gt;&lt;!-- #container --&gt;
  
  &lt;?php get_sidebar(); ?&gt;
  
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p>The problem is that the custom page don't add the right files (?). It (for example) don't add the right "more" link (its not the same as in front page), don't use CodeColorer (plugin for highlight code) and more. Whats the problem? How to fix it? I want to make the news look like in front page.</p>
  
  <p>loop.php</p>
  
  <pre><code>&lt;?php
  /**
   * The loop that displays posts.
   *
   * The loop displays the posts and the post content.  See
   * http://codex.wordpress.org/The_Loop to understand it and
   * http://codex.wordpress.org/Template_Tags to understand
   * the tags used in it.
   *
   * This can be overridden in child themes with loop.php or
   * loop-template.php, where 'template' is the loop context
   * requested by a template. For example, loop-index.php would
   * be used if it exists and we ask for the loop with:
   * &lt;code&gt;get_template_part( 'loop', 'index' );&lt;/code&gt;
   *
   * @package WordPress
   * @subpackage Twenty_Ten
   * @since Twenty Ten 1.0
   */
  ?&gt;
  
  &lt;?php /* Display navigation to next/previous pages when applicable */ ?&gt;
  &lt;?php if ( $wp_query-&gt;max_num_pages &gt; 1 ) : ?&gt;
      &lt;div id="nav-above" class="navigation"&gt;
          &lt;div class="nav-previous"&gt;&lt;?php next_posts_link( __( '&lt;span class="meta-nav"&gt;&amp;larr;&lt;/span&gt; Older posts', 'twentyten' ) ); ?&gt;&lt;/div&gt;
          &lt;div class="nav-next"&gt;&lt;?php previous_posts_link( __( 'Newer posts &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyten' ) ); ?&gt;&lt;/div&gt;
      &lt;/div&gt;&lt;!-- #nav-above --&gt;
  &lt;?php endif; ?&gt;
  
  &lt;?php /* If there are no posts to display, such as an empty archive page */ ?&gt;
  &lt;?php if ( ! have_posts() ) : ?&gt;
      &lt;div id="post-0" class="post error404 not-found"&gt;
          &lt;h1 class="entry-title"&gt;&lt;?php _e( 'Not Found', 'twentyten' ); ?&gt;&lt;/h1&gt;
          &lt;div class="entry-content"&gt;
              &lt;p&gt;&lt;?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?&gt;&lt;/p&gt;
              &lt;?php get_search_form(); ?&gt;
          &lt;/div&gt;&lt;!-- .entry-content --&gt;
      &lt;/div&gt;&lt;!-- #post-0 --&gt;
  &lt;?php endif; ?&gt;
  
  &lt;?php
      /* Start the Loop.
       *
       * In Twenty Ten we use the same loop in multiple contexts.
       * It is broken into three main parts: when we're displaying
       * posts that are in the gallery category, when we're displaying
       * posts in the asides category, and finally all other posts.
       *
       * Additionally, we sometimes check for whether we are on an
       * archive page, a search page, etc., allowing for small differences
       * in the loop on each template without actually duplicating
       * the rest of the loop that is shared.
       *
       * Without further ado, the loop:
       */ ?&gt;
  &lt;?php while ( have_posts() ) : the_post(); ?&gt;
  
  &lt;?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?&gt;
  
      &lt;?php if ( ( function_exists( 'get_post_format' ) &amp;&amp; 'gallery' == get_post_format( $post-&gt;ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?&gt;
          &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
              &lt;h2 class="entry-title"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?&gt;" rel="bookmark"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;span class="data"&gt;&lt;?php twentyten_posted_on(); ?&gt;&lt;/span&gt;&lt;/h2&gt;
  
              &lt;!--&lt;div class="entry-meta"&gt;
                  &lt;?php twentyten_posted_on(); ?&gt;
              &lt;/div&gt;--&gt;&lt;!-- .entry-meta --&gt;
  
              &lt;div class="entry-content"&gt;
  &lt;?php if ( post_password_required() ) : ?&gt;
                  &lt;?php the_content(); ?&gt;
  &lt;?php else : ?&gt;
                  &lt;?php
                      $images = get_children( array( 'post_parent' =&gt; $post-&gt;ID, 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'orderby' =&gt; 'menu_order', 'order' =&gt; 'ASC', 'numberposts' =&gt; 999 ) );
                      if ( $images ) :
                          $total_images = count( $images );
                          $image = array_shift( $images );
                          $image_img_tag = wp_get_attachment_image( $image-&gt;ID, 'thumbnail' );
                  ?&gt;
                          &lt;div class="gallery-thumb"&gt;
                              &lt;a class="size-thumbnail" href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php echo $image_img_tag; ?&gt;&lt;/a&gt;
                          &lt;/div&gt;&lt;!-- .gallery-thumb --&gt;
                          &lt;p&gt;&lt;em&gt;&lt;?php printf( _n( 'This gallery contains &lt;a %1$s&gt;%2$s photo&lt;/a&gt;.', 'This gallery contains &lt;a %1$s&gt;%2$s photos&lt;/a&gt;.', $total_images, 'twentyten' ),
                                  'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
                                  number_format_i18n( $total_images )
                              ); ?&gt;&lt;/em&gt;&lt;/p&gt;
                  &lt;?php endif; ?&gt;
                          &lt;?php the_excerpt(); ?&gt;
  &lt;?php endif; ?&gt;
              &lt;/div&gt;&lt;!-- .entry-content --&gt;
  
              &lt;div class="entry-utility"&gt;
              &lt;?php if ( function_exists( 'get_post_format' ) &amp;&amp; 'gallery' == get_post_format( $post-&gt;ID ) ) : ?&gt;
                  &lt;a href="&lt;?php echo get_post_format_link( 'gallery' ); ?&gt;" title="&lt;?php esc_attr_e( 'View Galleries', 'twentyten' ); ?&gt;"&gt;&lt;?php _e( 'More Galleries', 'twentyten' ); ?&gt;&lt;/a&gt;
                  &lt;span class="meta-sep"&gt;|&lt;/span&gt;
              &lt;?php elseif ( in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?&gt;
                  &lt;a href="&lt;?php echo get_term_link( _x( 'gallery', 'gallery category slug', 'twentyten' ), 'category' ); ?&gt;" title="&lt;?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?&gt;"&gt;&lt;?php _e( 'More Galleries', 'twentyten' ); ?&gt;&lt;/a&gt;
                  &lt;span class="meta-sep"&gt;|&lt;/span&gt;
              &lt;?php endif; ?&gt;
                  &lt;span class="comments-link"&gt;&lt;?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?&gt;&lt;/span&gt;
                  &lt;?php edit_post_link( __( 'Edit', 'twentyten' ), '&lt;span class="meta-sep"&gt;|&lt;/span&gt; &lt;span class="edit-link"&gt;', '&lt;/span&gt;' ); ?&gt;
              &lt;/div&gt;&lt;!-- .entry-utility --&gt;
          &lt;/div&gt;&lt;!-- #post-## --&gt;
  
  &lt;?php /* How to display posts of the Aside format. The asides category is the old way. */ ?&gt;
  
      &lt;?php elseif ( ( function_exists( 'get_post_format' ) &amp;&amp; 'aside' == get_post_format( $post-&gt;ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) )  ) : ?&gt;
          &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
  
          &lt;?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?&gt;
              &lt;div class="entry-summary"&gt;
                  &lt;?php the_excerpt(); ?&gt;
              &lt;/div&gt;&lt;!-- .entry-summary --&gt;
          &lt;?php else : ?&gt;
              &lt;div class="entry-content"&gt;
                  &lt;?php the_content( __( 'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyten' ) ); ?&gt;
              &lt;/div&gt;&lt;!-- .entry-content --&gt;
          &lt;?php endif; ?&gt;
  
              &lt;div class="entry-utility"&gt;
                  &lt;?php twentyten_posted_on(); ?&gt;
                  &lt;span class="meta-sep"&gt;|&lt;/span&gt;
                  &lt;span class="comments-link"&gt;&lt;?php comments_popup_link( __( 'Komentarze', 'twentyten' ), __( '1 Komentarz', 'twentyten' ), __( '% Komentarze', 'twentyten' ) ); ?&gt;&lt;/span&gt;
                  &lt;?php edit_post_link( __( 'Edit', 'twentyten' ), '&lt;span class="meta-sep"&gt;|&lt;/span&gt; &lt;span class="edit-link"&gt;', '&lt;/span&gt;' ); ?&gt;
              &lt;/div&gt;&lt;!-- .entry-utility --&gt;
          &lt;/div&gt;&lt;!-- #post-## --&gt;
  
  &lt;?php /* How to display all other posts. */ ?&gt;
  
      &lt;?php else : ?&gt;
          &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
  
  
              &lt;h2 class="entry-title"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?&gt;" rel="bookmark"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;span class="data"&gt;&lt;?php the_time( __( 'j')); ?&gt;&lt;span class="miesiac"&gt; &lt;?php the_time( __( 'M')); ?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
                      &lt;?php 
                          printf( __( '&lt;span class="meta-sep"&gt;by&lt;/span&gt; %1$s', 'pongsari' ),
                              sprintf( '&lt;span class="autor"&gt;&lt;a class="url fn n" href="%1$s" title="%2$s"&gt;%3$s&lt;/a&gt;&lt;/span&gt;',
                                  get_author_posts_url( get_the_author_meta( 'ID' ) ),
                                  sprintf( esc_attr__( 'View all posts by %s', 'pongsari' ), get_the_author() ),
                                  get_the_author()
                              )
                          );
                      ?&gt;
          &lt;!--    &lt;div class="entry-meta"&gt;
                  &lt;?php twentyten_posted_on(); ?&gt;
              &lt;/div&gt;--&gt;
              &lt;!-- .entry-meta --&gt;
  
      &lt;?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?&gt;
              &lt;div class="entry-summary"&gt;
                  &lt;?php the_excerpt(); ?&gt;
              &lt;/div&gt;&lt;!-- .entry-summary --&gt;
      &lt;?php else : ?&gt;
              &lt;div class="entry-content"&gt;
                  &lt;?php the_content( __( 'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyten' ) ); ?&gt;
                  &lt;?php wp_link_pages( array( 'before' =&gt; '&lt;div class="page-link"&gt;' . __( 'Pages:', 'twentyten' ), 'after' =&gt; '&lt;/div&gt;' ) ); ?&gt;
              &lt;/div&gt;&lt;!-- .entry-content --&gt;
      &lt;?php endif; ?&gt;
  
              &lt;div class="entry-utility"&gt;
                  &lt;?php if ( count( get_the_category() ) ) : ?&gt;
                      &lt;span class="cat-links"&gt;
                          &lt;?php printf( __( '&lt;span class="%1$s"&gt;Kategoria&lt;/span&gt; %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?&gt;
                      &lt;/span&gt;
                      &lt;span class="meta-sep"&gt;|&lt;/span&gt;
                  &lt;?php endif; ?&gt;
                  &lt;?php
                      $tags_list = get_the_tag_list( '', ', ' );
                      if ( $tags_list ):
                  ?&gt;
                      &lt;span class="tag-links"&gt;
                          &lt;?php printf( __( '&lt;span class="%1$s"&gt;Tagged&lt;/span&gt; %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?&gt;
                      &lt;/span&gt;
                      &lt;span class="meta-sep"&gt;|&lt;/span&gt;
                  &lt;?php endif; ?&gt;
                  &lt;span class="comments-link"&gt;&lt;?php comments_popup_link( __( 'Komentarze', 'twentyten' ), __( '1 Komentarz', 'twentyten' ), __( '% Komentarze', 'twentyten' ) ); ?&gt;&lt;/span&gt;
                  &lt;?php edit_post_link( __( 'Edit', 'twentyten' ), '&lt;span class="meta-sep"&gt;|&lt;/span&gt; &lt;span class="edit-link"&gt;', '&lt;/span&gt;' ); ?&gt;
              &lt;/div&gt;&lt;!-- .entry-utility --&gt;
          &lt;/div&gt;&lt;!-- #post-## --&gt;
  
          &lt;?php comments_template( '', true ); ?&gt;
  
      &lt;?php endif; // This was the if statement that broke the loop into three parts based on categories. ?&gt;
  
  &lt;?php endwhile; // End the loop. Whew. ?&gt;
  
  &lt;?php /* Display navigation to next/previous pages when applicable */ ?&gt;
  &lt;?php if (  $wp_query-&gt;max_num_pages &gt; 1 ) : ?&gt;
                  &lt;div id="nav-below" class="navigation"&gt;
                      &lt;div class="nav-previous"&gt;&lt;?php next_posts_link( __( '&lt;span class="meta-nav"&gt;&amp;larr;&lt;/span&gt; Older posts', 'twentyten' ) ); ?&gt;&lt;/div&gt;
                      &lt;div class="nav-next"&gt;&lt;?php previous_posts_link( __( 'Newer posts &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyten' ) ); ?&gt;&lt;/div&gt;
                  &lt;/div&gt;&lt;!-- #nav-below --&gt;
  &lt;?php endif; ?&gt;
  </code></pre>