Forums

How do i combine POSTS and PAGES in one listing? (6 posts)

  1. expat
    Member
    Posted 6 months ago #

    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

  2. Big Bagel
    Member
    Posted 6 months ago #

    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.

  3. expat
    Member
    Posted 6 months ago #

    How can I merge a couple of query_posts??

    array_merge( query_posts(), query_posts() );

  4. Big Bagel
    Member
    Posted 6 months ago #

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

  5. expat
    Member
    Posted 6 months ago #

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

  6. Big Bagel
    Member
    Posted 6 months ago #

    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.

Reply

You must log in to post.

About this Topic