Hi, all. Does anyone know what code I should add to functions.php in order to have a homepage that will display full posts for posts that DON'T have any content in the manual-excerpt field, and that will display ONLY the manual excerpt for posts that DO have content in the manual-excerpt field?
ThemeShaper Forums » Thematic
Mix full posts & manual excerpts on homepage
(5 posts)-
Posted 1 year ago #
-
Wow, really? I figured this would be an easy one (you know, easy for someone other than me, because I apparently am of limited intelligence and can't figure this out on my own).
If it helps: Here's how it's accomplished by editing the template files directly instead of accomplishing it via the elusive code I'm looking to place in functions.php:
If you only want WordPress to display a manually added excerpt and you don“t want WordPress to automatically generate any excerpts for you, then in your index.php file follow the instructions in the code below:
//Replace the_excerpt() template tag <?php the_excerpt(); ?> //With this: <?php if ( $post->post_excerpt ) the_excerpt(); ?>Posted 1 year ago # -
Well, it took me all day, but I finally sussed it out on my own.
In case anyone's interested, this is what I added to functions.php:function childtheme_content($content) { global $post; if (is_home() || is_front_page()) { if ($post->post_excerpt) { $content = 'excerpt';} else { $content = 'full'; } } elseif (is_single()) { $content = 'full'; } elseif (is_tag()) { $content = 'excerpt'; } elseif (is_search()) { $content = 'excerpt'; } elseif (is_category()) { $content = 'excerpt'; } elseif (is_author()) { $content = 'excerpt'; } elseif (is_archive()) { $content = 'excerpt'; } return $content; } add_filter('thematic_content', 'childtheme_content');Posted 1 year ago # -
didn't see this until just now. nice solve. when filtering, you don't have to copy over the entire function if you aren't making changes.
function childtheme_content($content) { global $post; if (is_home() || is_front_page()) { if ($post->post_excerpt) { $content = 'excerpt';} else { $content = 'full'; } } return $content; } add_filter('thematic_content', 'childtheme_content');this should also work the same
Posted 1 year ago # -
Great. Thanks, Kathy. I'll trim it down. :)
Posted 1 year ago #
Topic Closed
This topic has been closed to new replies.