Wordpress: Controlling the_excerpt

I have a sidebar that includes an excerpt of a specific page.

When viewing the index.php, the excerpt appears in the sidebar properly. When viewing a single.php post, the sidebar displays the full content of the specific page, instead of an excerpt.

I want it to always and only show an excerpt of a specific page in the sidebar. I need it to be unrelated to whether or not you’re on index.php, single.php or anything like that. How can this be done?

Are you using a sidebar widget? I sounds like the code in your theme files is different for “index” and “single”. eg.

<?php the_excerpt(); ?>

I’m not using a widget. I’m using get_posts to obtain the excerpt of a specific page ID. This is my code:


<?php global $post; $myposts = get_posts('numberposts=1&post_type=page&include=2'); ?><!-- DEFINE PAGE ID FOR ABOUT PAGE -->
			
			<?php if( isset( $myposts ) && $myposts != '' ) :?>
				<li><img src="<?php bloginfo('template_directory'); ?>/images/subhed_about.gif" alt="About"><br />
					<?php foreach($myposts as $post) : setup_postdata($post);?>
					<ul><?php the_excerpt(); ?><br />
					<a href="<?php the_permalink(); ?>">Read More</a></ul>
				<?php endforeach; ?>
				</li>
<?php endif;?>

That’s from the correctly working index.php file? Is the single.php file using the_content() instead? Or maybe there’s a conditional in it like

<?php if ( is_category() || is_archive() ) {
	the_excerpt();
} else {
	the_content();
} ?>

Do you use the <!–more–> tag in your posts?

It’s from the correctly working sidebar which is placed inside the index.php and single.php. However when you’re viewing this sidebar.php within the single.php it shows the_content instead of the_excerpt.

I want it to always show the_excerpt. Never the_content.

If it’s the same code in all the template files, I think you’ll need to use the more tag (to create a “teaser” or edit the post in question manually by adding an excerpt for WP to use on non-index pages. The info here should clear things up http://codex.wordpress.org/Excerpt