Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Background: I have a multisite install, where users have their own blogs. I'm working on a page for the main site which will list the most recently updated blogs and excerpts from the first three (WIP version here: http://threemix.co.uk/blog-network/ )

One of my users runs a video blog. Unfortunately, this messes up the excerpts when his is one of the most recent three updated blogs: more specifically, neither the excerpt nor a link to the post show (his blog is "Greg Does Reading" on the link above).

<section class="network-posts">
    <?php
    $thisblogid = get_current_blog_id();
    $blogs = get_last_updated('', 1, 12);
    $blogno = 1; 

    foreach ($blogs as $blog) : 
        switch_to_blog($blog['blog_id']); 
        global $post; 
        $myposts = get_posts(array('numberposts'=>1)); 
    ?>

    <?php if ($blogno == 1) { ?>
        <ul class="fresh">
    <?php } if ($blogno >= 1 && $blogno <= 3) { ?>
        <li class="fresh col-<?php echo (($blogno % 3)); ?> <?php if (count($myposts) == 0) : echo('no-posts'); endif;?>">
        <section><hgroup>
        <a href="<?php bloginfo('url'); ?>"><h2><?php bloginfo('title'); ?></h2></a>
        </hgroup>

        <ul>
        <?php $i = 0; foreach ($myposts as $post) : setup_postdata($post); ?>
            <li>
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br/>
            <?php echo get_my_excerpt(15); ?>  
            </li>
        <?php $i++; endforeach; ?>
        </ul>
        </section></li>
    <?php } if ($blogno == 3) { ?>
        </ul>
    <?php } if ($blogno > 3) { 
        // if not one of the first three posts ?>
            //ommitted for brevity        

    <?php } $blogno++?>

<?php endforeach; ?>

<?php switch_to_blog($thisblogid) ; ?>

</section>

The first three posts are generated in the inner tags. I am switching to each blog in order, taking the $post object of the most recent post, and using it in a custom loop.

Two questions:

  1. Why is the post's title not showing up? I can understand why the excerpt isn't, but not the post title.
  2. How can I change my get_my_excerpt() function (which at the moment, just changes the length of the excerpt), to include embedded YouTube videos?
share|improve this question

1 Answer 1

Try this:

global $wp_embed;
if ( get_option('embed_autourls') )
    remove_filter('the_content',array(&$wp_embed,'autoembed'));

// do excerpt/content stuff

if ( get_option('embed_autourls') )
    add_filter( 'the_content', array(&$wp_embed, 'autoembed'), 8 );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.