Title: Custom Post Type in index.php loop and navigation problem
Last modified: August 20, 2016

---

# Custom Post Type in index.php loop and navigation problem

 *  [vdowsett](https://wordpress.org/support/users/vdowsett/)
 * (@vdowsett)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/custom-post-type-in-indexphp-loop-and-navigation-problem/)
 * I have tried several codes to get the custom post type called in my index file
   loop that also works with the page navigation. If someone could maybe review 
   these code snippets and tell me what I’m doing wrong I’d really appreciate it.
 * First code snippet – calling custom post type works, but page navigation doesn’t:
 *     ```
       <?php
       // on front page
       $args = array(
         'post_type' => array('post','events'),
       );
       query_posts($args);
       ?>
       ```
   
 * Second code snippet – Page navigation works but the custom post type -events-
   is not displaying:
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts( array( 'post_type' => array('post','events'), 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC' ).get_option('posts_per_page').'&paged=' . $paged );
       ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/custom-post-type-in-indexphp-loop-and-navigation-problem/#post-2943866)
 * Why are you appending string values to an array?
 *     ```
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts(
         array(
           'post_type' => array('post','events'),
           'posts_per_page' => 10,
           'orderby' => 'date',
           'order' => 'DESC'
         ).get_option('posts_per_page').'&paged=' . $paged );
       ```
   
 * That isn’t going to give you the results you want. Try `echo array('a').'b'.'
   c';` You get `Arraybc`. You need to feed `query_posts` either a query-string-
   like string or an array, but not both at once.

Viewing 1 replies (of 1 total)

The topic ‘Custom Post Type in index.php loop and navigation problem’ is closed 
to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [index](https://wordpress.org/support/topic-tag/index/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [navigation](https://wordpress.org/support/topic-tag/navigation/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/custom-post-type-in-indexphp-loop-and-navigation-problem/#post-2943866)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
