The MU forums have moved to WordPress.org

Basic query posts with blog id (14 posts)

  1. zone19
    Member
    Posted 14 years ago #

    Hi Can someone please help me with a a query to get any specific post to show on my main blog homepage

    How do i adapt this?
    <?php $the_query = new WP_Query('');

    I want to get this post
    blogid=10&postid=6

    Any ideas?

    If you can suggest the best query method to allow for flexible presentation of attachments, more tag etc...
    Thanks

  2. zone19
    Member
    Posted 14 years ago #

    Ok maybe i should describe what i want to do better?

    I want to display selected posts on the main blog from the community via blogid & postid

    There are a few different ways to query the database.
    Can i please get an example which hopefully also provides the ability to include podpress attachments?

    Thanks
    fleetfm.com Admin

  3. zone19
    Member
    Posted 14 years ago #

    Anyone, Anyone...
    Beuller? Beuller?...

  4. lunabyte
    Member
    Posted 14 years ago #

  5. tdjcbe
    Member
    Posted 14 years ago #

    You want the contect of a specific post from a specific blog to appear on your home page?

    Best bet would be copy and paste.

  6. jamescollins
    Member
    Posted 14 years ago #

    I haven't tried it myself, but doing something like this may work:

    // switch to blog id 10
    switch_to_blog(10);
    $the_query = new WP_Query('postid=6');
    while($the_query->have_posts()) : $the_query->the_post();
    // display post here
    endwhile;
    restore_current_blog();
  7. andrea_r
    Moderator
    Posted 14 years ago #

    So basically what you're *really* looking to do is a featured post?

  8. zone19
    Member
    Posted 14 years ago #

    Thanks James,

    Awesome, now i can pull any post from any blog onto my front page!

    well almost - at the moment it's grabbing all the posts from that blog. What other argument can i try?
    'postid=6' just ain't cutting it

    $the_query = new WP_Query('postid=6');

    I've tried numberposts=1
    and also include=6

    but it still gets all the posts from that particular blog

    Any ideas why these arguments aren't working?

  9. jamescollins
    Member
    Posted 14 years ago #

    Hi,

    Try something like this instead:

    $the_query = new WP_Query();
    $the_query->query('postid=6');

    Again, not sure if it works or not.

  10. zone19
    Member
    Posted 14 years ago #

    switch_to_blog(10);
    $postslist = get_posts('numberposts=1&include=6');
    foreach ($postslist as $post) :
    setup_postdata($post);
    // display post here
    endforeach;
    restore_current_blog();

    This works !
    now if i can just get the podcast attachments code to work as per this link below:

    http://codex.wordpress.org/Template_Tags/get_posts#Show_all_attachments

  11. zone19
    Member
    Posted 14 years ago #

    hallelujah!

    switch_to_blog(10);
    query_posts("p=6");
    while (have_posts()) : the_post();

    // display post here (attachments included)

    endwhile ;
    restore_current_blog();

    This was "the best query method to allow for flexible presentation of attachments, more tag etc..." as i initially asked...

    How is this not common knowledge???
    query posts - Post & Page Parameters
    http://codex.wordpress.org/Template_Tags/query_posts#Post_.26_Page_Parameters

    Anyway, thanks for your help people - especially James!

  12. jamescollins
    Member
    Posted 14 years ago #

    Glad to hear you got it working zone19.

  13. DailyTestimony
    Member
    Posted 14 years ago #

    Thats the complicated way IMO, you could have used this function:

    get_blog_post ( $blog_id, $post_id )

  14. zone19
    Member
    Posted 14 years ago #

    Thanks Mr/Ms Testimony,

    but does that hook allow for flexible presentation?

    I'd like to pull a list of recent podcasts

    anyone know the most elegant way to do this?

About this Topic