I want to add Featured Images to Recent Global Posts

As it says in my title I would like to add images to my Recent Global Posts Feed . I am not afraid of a little code if someone can talk me through it.

Thanks

  • Michael Bissett

    Hi @Missterbig, hope you're doing well this evening! :slight_smile:

    One thing you can try would be replacing this code on line 65 of recent-global-posts-feed/recent-global-posts-feed.php:

    <?php while( network_have_posts()) : network_the_post(); ?>

    With this:

    <?php while( network_have_posts()) : network_the_post();
    				switch_to_blog($network_post->BLOG_ID);         
    
    		        //Get network blog post featured image
    		        $featured_image_id = get_post_thumbnail_id(network_get_the_ID());
    		        $featured_image_src = '';
    		        if ($featured_image_id) {
    		            $featured_image_src = array_shift(wp_get_attachment_image_src($featured_image_id, 'thumbnail'));
    		        }     
    
    		        //Network blog name
    		        $blogname = get_blog_option($network_post->BLOG_ID, 'blogname');
    
    		        restore_current_blog();
    		    ?>

    (please make a backup of the file first, just to be safe :slight_smile: )

    Let me know if this helps please! :slight_smile:

    Kind Regards,
    Michael

  • Missterbig

    Hi Michael,
    I apologize I got confused on the plugin name because you guys seem to have several that are doing the same thing. This 'Recent Global Post Feed' has no control over the amount of posts or anything. I think I was referring to the 'Recent Network Posts' one with the shortcode.

    Maybe I should just explain what I want to do and you can recommend something for me. I have Post Indexer installed and I just want to display 5 or so recent GLOBAL posts from a few different categories on my main page. I need a plugin that will display the Permanent link, The Title, and The featured Image. Sounds simple enough but I can't seem to find anything that suits my needs exactly. This can also be a widget but I MUST have featured images and that is where I seem to be running into problems.

    Any help would certainly be appreciated.