The MU forums have moved to WordPress.org

Need some help with php (6 posts)

  1. Konstan
    Member
    Posted 15 years ago #

    I've been trying to adapt the ah_recent_posts_mu to show the latest posts from blogID 2 but it will only display 1 post.

    Could anyone help me with what seemed like an easy thing to do? I am trying to show the latest 3 posts from blog ID 2, all I need to display is the title, post content and the post url.

    Or if anyone knows of any plugin I can try to learn the code from, let me know. I am not very good with this and its the last thing I need working to update my page.

  2. dsader
    Member
    Posted 15 years ago #

    I use the following approach(no plugins) in my index.php using mostly the stuff found in most every index.php:

    switch_to_blog(2);

    http://codex.wordpress.org/Template_Tags/query_posts

    Hint: $query = new WP_Query($query_string);

    http://codex.wordpress.org/The_Loop

    restore_current_blog();

  3. andrea_r
    Moderator
    Posted 15 years ago #

    ah_recent_posts_mu will only show posts within the last 24 hours. :) That might be the issue.

    If you're just pulling from one specific blog, you might want to also try parsing the feed.
    http://wpmututorials.com/plugins/how-to-display-users-blog-posts-feed-on-your-main-page/

  4. MrBrian
    Member
    Posted 15 years ago #

    Try pasting your code using pastebin.com so we can take a look. If it's displaying 1 post, you can probably assume there's a problem with your loop or the query :).

  5. andrea_r
    Moderator
    Posted 15 years ago #

    I already know the code he's using* :) , and now that I think about it, it only shows *ONE POST* from each blog. on purpose.

    If you want more than one post from only one blog, I'd suggest a different solution. like the one I posted above.

    * any function reference with ah_ in front of it is us, as in me & ron.

  6. Konstan
    Member
    Posted 15 years ago #

    Yeah, I ended up going another way :P Just took the Featured Blog plugin and made it show the latest post from blog id 2. It ended up looking better than with 3 posts.

About this Topic