The MU forums have moved to WordPress.org

Display posts from a specific blog and category (8 posts)

  1. mptre
    Member
    Posted 15 years ago #

    Hi there,
    I'm trying to figure out how to display posts from a specific WordPress MU blog and a specific category on the MU-homepage for the blogs. Google didn't serve me the answer this time. Any thoughts?

    Thanks!

  2. andrea_r
    Moderator
    Posted 15 years ago #

    Pull the category feed of that blog and parse it on the home page. :)

  3. Klark0
    Member
    Posted 15 years ago #

    This'll grab the last 5 posts from category id = 1 of blog id = 2

    <ul>
    <?php
    switch_to_blog(2); ?>
    <?php $recent = new WP_Query("showposts=5&cat=1");
    while($recent->have_posts()) : $recent->the_post(); ?>
    <li>
    \\INSERT TEMPLATE TAGS HERE
    </li>
    <?php endwhile ; ?>
    <?php restore_current_blog();
    ?>
    </ul>
  4. mptre
    Member
    Posted 15 years ago #

    Thanks for all replies, Klarkos method worked out fine!

  5. mptre
    Member
    Posted 15 years ago #

    I recently discovered one problem. I'm using the code below, thanks to Klarko, to display posts from a specific blog and category on the MU homepage. Works fine there. But when I move to a different page on the homepage the 'Read more' links doesn't work it displays the whole post content instead. Any thoughts on this?

    This is the code I'm using atm.

    http://pastie.org/private/ny3uetek2z7ru2judua

  6. Klark0
    Member
    Posted 15 years ago #

    Read more will only work if your users set it when they're writing their posts. So you can't depend on that. Use the_excerpt and the_permalink together instead.

  7. mptre
    Member
    Posted 15 years ago #

    @Klarko: I'm using the <!-- more --> tag on each post. The strange is that the the_content('Read more') works fine on the startpage but not on page that belongs to the startpage. The the_excerpt() works just like the_content(), fine on the startpage of the homepage but not on a page that belongs to the homepage.

  8. mptre
    Member
    Posted 15 years ago #

    Nevermind, solved it using get_the_content() and substr().

About this Topic