How to Make Post Formats Display in Sidebar (2 posts)

  1. missbritt
    Posted 4 years ago #

    I use aside posts on my site http://inpursuitofhappiness.net to create the category "weekly challenge." I did some hacking to allow aside posts to have an excerpt, and display that excerpt on the home page.

    This is the code I use to display the excerpt on the home page:

    <?php $myposts = get_posts(array('numberposts' => 1, 'post_type' => 'weekly_challenge')); ?>
    <?php foreach( $myposts as $post ) : setup_postdata($post); ?>
                    <div style="padding: 10px; font-family: Arial, Helvetica, Geneva, sans-serif;">
                        <?php the_excerpt(); ?>
                        <div><a href="<?php echo get_home_url( 1, '/weekly-challenge/'); ?>" style="font-size: 10px;">More Weekly Challenges &rarr;</a></div>
    <?php endforeach; ?>

    I am using the PHP Code Widget plugin to paste that same code (minus the padding) into a sidebar widget to show up at http://inpursutifohappiness.net/blog, but it doesn't seem to be working.

    On the blog homepage it displays the first 55 characters excerpt instead of the one I created. On individual blog posts, it pulls the excerpt for the most recent post.

    Any ideas?

  2. luckdragon
    Posted 4 years ago #

    above that, try adding:
    <?php global $post; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic