All good examples. But they weren’t working for me with the theme (pinboard) and plugin I was using (secondary-html-content) and what I wanted to do.
The first challenge was to make sure that I get both pieces of content instead of just one. The second challenge was to replace the excerpt on the homepage with the actual content.
So I created a new plugin that does this:
function okmAddingContentExcerpt() {
global $post;
$content="<div class="comment-first">".$post->post_content.'</div>';
// Adia Review is the name of the label from secondary-html-content plugin
$content .= '<div class="comment-second">'.get_secondary_content('Adia Review',$post->ID).'</div>';
return $content;
}
add_filter('the_excerpt', 'okmAddingContentExcerpt');
function okmAddingContentSingle() {
global $post;
$content="<div class="comment-first">".$post->post_content.'</div>';
// remove the filter so that it doesn't loop over and over
remove_filter('the_content','okmAddingContentSingle');
$content .= '<div class="comment-second">'.get_secondary_content('Adia Review',$post->ID).'</div>';
return $content;
}
add_filter('the_content', 'okmAddingContentSingle');
Notice how I wanted to keep the content instead of the excerpt on the main page.
Oh yeah, if you want to download the plugin, I added it to my blog-site: http://okmaya.com/wordpress-plugin-for-pinboard-theme-and-secondary-html-content-plugin/