WordPress.org

Forums

Latest Network Posts & Wrong Blog Listed (7 posts)

  1. milkisethian
    Member
    Posted 1 year ago #

    Hi,

    I'm fairly new to WordPress and to multisites in particular.

    I have an issue with a Latest Network Post widget displaying correctly on the main/home site but incorrectly on the subsites. The Latest Network Posts links are correct but the text after ("in DNA Science Blog") show only the name of the current subsite. The widget is built-in, in the functions.php file. Some multisite snafu is going on but I can't figure out what to do.

    Help appreciated!

    Examples:
    Look at the link list below one of these headers in the first widget area, Latest PLoG Posts or Latest Network Posts.

    http://blogs.plos.org/neuroanthropology/
    http://blogs.plos.org

    MU plugins:
    Select WordPress MU Sitewide Tags Pages
    WordPress MU Sitewide Tags Pages

    functions.php code:

    http://pastebin.com/raw.php?i=5pa2tYNu

  2. The main site is the tags blog, right? So that's why IT shows all the posts. The subsite just shows it's own posts.

  3. milkisethian
    Member
    Posted 1 year ago #

    Yes, the main site is the tags blog.

    Must admit I'm a bit confused about the "tags blog" thing.
    It's enabled and set to "tags".

    Is there a way to maintain those settings and display the proper blogname associated with the links displaying on the subsites?

    The subsite is correctly showing post links from the other subsites in the main network but the text following the link "in..." is displaying only the name of whatever subsite the widget is displaying on, not the blog name corresponding with the post link.

    Thanks for your help.

  4. Tags blog collects all posts from all sites on the network.

    Each other site has just itself.

    Is there a way to maintain those settings and display the proper blogname associated with the links displaying on the subsites?

    Only with some fancy DB queries or a widget that calls back to the tags site for the posts using switch to blog.

  5. milkisethian
    Member
    Posted 1 year ago #

    Thanks for the clarification about the tags blog.

    Would a blog switch and restore like this possibly work?

    switch_to_blog( $blog_id );
    // Do something
    restore_current_blog();

  6. Yes but ... there may be some catches (like permalinks being weird) and it may slow your site down.

  7. milkisethian
    Member
    Posted 1 year ago #

    Thanks for the advice thus far.

    I'm wondering if I can adapt the code used for the Latest Network Comments since that displays the correct blog name after the links:

    See the list of comments at the bottom of this page:
    http://blogs.plos.org/obesitypanacea/

    CODE:

    // Format the HTML output
       $html = '
    <ul>';
       foreach ( $recent_comments_across_network as $comment ) {
    		$c = $comment->comment_content;
    		if (strlen($c) > 40) {	$c = strip_tags(substr($c, 0, 41)) . '...'; }
    		$bn = get_blog_option($comment->blog_id, 'blogname');
    
    		$html .= '
    <li><a>blog_id, $comment->comment_post_ID ).'">';
    		$html .= $c . '</a> by ' . $comment->comment_author . ' in ' . $bn . '</li>
    ';
       }
       $html .= '</ul>
    ';
    
       return $html;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic