0

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?

1 Answer 1

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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