Featured Image in Global Posts

I'm not much of a programmer, how would I go about changing the avatar in the recent global post widgets to being the featured image in the post or the first image uploaded to a post?

I'm also looking to be able to display blocks of posts from different blogs on the site. Since my network isn't open to registration I can make sure whatever is needed in each blog to pull it from (like a featured category), but I'd like to be able to showcase a block of posts from each blog with the post image rather than the author avatar. Ie 4 posts from blog id 3 with the post image.

I'm beginning level with php but good with css so when I look at the example code I was given

<br />
switch_to_blog($blog_id):<br />
get_post_mets($post_id, 'whatever');<br />
restore_current_blog();

Is confusing to me. If I saw the code in action I could likely make it work.

Any help would be appreciated. Basically I'm trying to build a magazine type site where different topics are in their own blogs so I can brand each blog differently.

Any help would be greatly appreciated.

  • Mason
    • DEV MAN’s Sidekick

    Hiya!

    It'd be a fairly complex, as a beginner, to create the functions you're looking for - and you'd have to modify the Recent Global Posts Widget which would be an issue for upgrades.

    A developer should be able to get this done for you, so my advice would be to check out our WPMU Job boards and post a request there.

    That being said, I'm not sure where you're getting the sample code above, but looking at line 165 in widget-recent-global-posts.php is where the call for get_avatar takes place. You could start by replacing that function ;D

    Hope this helps somewhat!

    Thanks.

  • maladymg
    • WPMU DEV Initiate

    I'm not one for paying other people to do the work for me.. I learn nothing that way. It doesn't matter how complex it is, if I can find the information to get it together I can do it myself. I find it difficult to believe it would be extremely complicated to pull blog posts from a specific blog to the front page of the main blog. Perhaps you are misunderstanding what I'm asking for. I'm a beginner at php but I know the wordpress loop fairly well, I design wordpress themes for a living. This is my first venture into multi blogs.

    I guess paying as much as this cost I was expecting a higher level of support. I can get a hire a coder response anywhere.
    Thanks.

  • Mason
    • DEV MAN’s Sidekick

    Hiya,

    Wasn't my intention to sound like there was no other option than hiring a developer.
    You definitely can do it!

    I'd start here for the function to grab an image from a post:
    http://codex.wordpress.org/Function_Reference/the_post_thumbnail

    Next take a look at how the widget pulls the author avatar (this is the section I mentioned around line 165) and make a replacement there as you don't want the avatar, you want post images.

    Again, this should help you get started. Let us know how it goes! :smiley:

  • maladymg
    • WPMU DEV Initiate

    Thanks, I wasn't sure if it was usually different calls since its MU and not regular wordpress. I think where my confusion lies is how do I pull it from a specific blog. In regular wordpress I can pull from a category or a custom form field, tag etc... In the widget and recent global posts plugin that is not the widget it pulls from all the blogs. I'm trying to figure out how to specify by blog or blog category in a specific blog number. It doesn't have to be in a sidebar widget, in fact I'd prefer that it wasn't. I guess i was asking more than one question.

    In regular wordpress if I want to pull a specific category I can use a code similar to

    <code><?php $recent = new WP_Query("cat="xxxxxx"&showposts="('4')); while($recent->have_posts()) : $recent->the_post();?><br />
    				<?php if( get_post_meta($post->ID, "thumb", true) ): ?><br />
    				<a>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=75&w=75&zc=1" alt="<?php the_title(); ?>" /></a></code>

    I'm not sure how to pull this from category "featured" in blog id 6

    I appreciate the response. Thanks for your help.

  • Ulrich
    • The Crimson Coder

    Add switch_to_blog(6); //blog id is 6 before the code you would use for a simple wordpress install, and restore_current_blog(); after it.

    So, for the example code you provided, you would do:

    <?php switch_to_blog(6); ?>
    <?php $recent = new WP_Query("cat="xxxxxx"&showposts="('4')); while($recent->have_posts()) : $recent->the_post();?>
    <?php if( get_post_meta($post->ID, "thumb", true) ): ?>
    " rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=75&w=75&zc=1" alt="<?php the_title(); ?>" />
    <?php endif; endwhile; ?>
    <?php restore_current_blog(); ?>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.