• 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)
  • 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.