The MU forums have moved to WordPress.org

Displaying Thumbnails/Custom Fields (4 posts)

  1. anonymized_303747
    Member
    Posted 15 years ago #

    Relatively new to WPMU but lovin' it so far.

    I am running into the following issue:

    1. I am displaying the 3 latest posts from blog X on my main WPMU blog using a simple loop and switch_to_blog/restore_current_blog.

    <?php switch_to_blog(7); ?>
    <?php if(have_posts()) :
    $recent = new WP_Query("showposts=3");
    while($recent->have_posts()) : $recent->the_post(); ?>
    <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title() ?></a></h2>
    <img src="<?php echo get_option('lead_image'); ?><?php $values = get_post_custom_values('lead_image'); echo $values[0]; ?>" alt="" />
    <?php the_content_limit(200, ""); ?>
    <?php restore_current_blog(); ?>
    <?php endwhile; else: ?>
    <h2>No matching results</h2>
    <?php endif; ?>

    I am calling a custom field called "lead_image" to display a thumbnail for each post using:

    <img src="<?php echo get_option('lead_image'); ?><?php $values = get_post_custom_values('lead_image'); echo $values[0]; ?>" alt="" />

    Now, this works fine for the first post. Thumbnail shows, first 200 characters of the post show. Post 2 and 3 show the 200 character summary - but the value for custom field lead_image isn't loaded and no thumbnail is displayed.

    Any ideas on how to do this?

  2. easysleeper
    Member
    Posted 15 years ago #

    perhaps move <?php restore_current_blog(); ?> outside of the loop?

    If that doesn't work I'll look closer at it for you, I've got some free time, and this may be useful to me later ;)

  3. anonymized_303747
    Member
    Posted 15 years ago #

    That was exactly it - when I think about it, it's pretty obvious why what I had didn't work!

    Thanks much, easysleeper!

  4. tuviere
    Member
    Posted 14 years ago #

    I know this is not related to your topic but am desperate, how do i get to display thumbnail in my rss feeds

About this Topic