• Hi all, i’m currently building my portfolio and on the home page i am going to have various items pulled from my news as well as my custom posts, i want to show them all in a random order. Obviously i can get it to show my posts and then my custom posts but i want to load them all in and then show them all mixed together?

    What should i be looking at to do this?

    Thanks
    Dan

Viewing 5 replies - 1 through 5 (of 5 total)
  • query_posts

    I think you can do an array for post_type parameter ??

    Thread Starter danhodkinson

    (@danhodkinson)

    I’ve looked around but not really been able to find anything. Basically I am going to load in x amount of posts and the x amount of a few different custom posts. Is it possible to set up these different amounts in an array?

    Thanks
    Dan

    You can specify showposts but it worked for both custom post type you are showing. If you can create ONE loop you can specify each parameter ONCE. You can show 10 post from default post and custom post types.

    Thread Starter danhodkinson

    (@danhodkinson)

    Sorry i don’t really follow you.

    in non-code terms i am trying to do the following:

    loop = posts x10 , portfolio x4 , photos x5, links x5

    show loop (random order)

    {
    if portfolio{ do x}
    else if photos {do y}
    etc
    }

    so i dont know if i am able to load in this kind of thing:

    <?php $loop = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => 2, 'order' => 'ASC') ); ?>

    into one big loop which outputs everything in a random order.

    Dan

    Thread Starter danhodkinson

    (@danhodkinson)

    Ok so i kind of having it working using this code:

    <?php
    //first query
    $favourite = get_posts(array(
    
    		'post_type' => 'favourite',
    		'post_status' => 'publish'
     		));
    //second query
    $portfolio = get_posts(array(
    		'post_type' => 'portfolio',
    		'post_status' => 'publish',
    		'posts_per_page' => 3
     		));
    $mergedposts = array_merge( $favourite, $portfolio ); //combine queries
    
    foreach( $mergedposts as $post ) {
    query_posts( $post );
    the_title();?> <br/>
    <?php } ?>

    the only thing i can’t figure out is how to display the $mergedposts randomly?

    i tried making a new array for it but that didn’t work? Can’t think what else to do?

    Thanks for any help

    Dan

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Loading in Posts & Custom Posts and then displaying them’ is closed to new replies.