• How do i combine POSTS and PAGES in one listing?

    How can I combine them both into one listing? I do have a category/tag plugin that combines them both BUT need to know how to do it in the templates independently

    cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • It depends on exactly where you want to do this and how you want them displayed, but you can start by creating a custom query that returns both posts and pages:

    $args = array(
        'post_type' => array(
            'post',
            'page'
        )
    );
    
    $my_query = new WP_Query( $args );

    You can find other parameters here:

    http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

    Then you would just loop through the returned posts/pages and display them however you want.

    Thread Starter expat

    (@expat)

    How can I merge a couple of query_posts??

    array_merge( query_posts(), query_posts() );

    query_posts is for altering the main loop. What are you wanting to accomplish?

    Thread Starter expat

    (@expat)

    i got two query_posts, one for pages and one for posts in an IF statement, need them both in a slider

    For secondary loops using get_posts or manually creating new WP_Query objects like my example above is generally the way to go.

    Template Tags/get posts
    Class Reference/WP Query

    Without knowing specifically what you’re looking to do (including your current queries or what posts/pages you’re looking to query for, the order of their display, what exactly you mean by a slider, etc.) it’s difficult to comment on anything else.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do i combine POSTS and PAGES in one listing?’ is closed to new replies.