• I’m not much of a coder, so am struggling to create a function (in functions.php) that will allow me to display the excerpts for posts in one category and the full post for another category. Here’s what I have so far. The excerpts for category 8 displays, but other categories display the words “the_content”.

    // show full post or excerpt on categories
    function post_length_choice($content) {
    //    if (is_category( array(1, 22, 23))) {
         if (is_category(8)) {
             $content= 'the_excerpt';
         } else if  (is_category()) {
             $content= 'the_content';
         }
         return $content;
    }
    add_filter('the_content', 'post_length_choice');
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Modify your code to call the right functions that return values instead of echoing them out.

    if (is_category(8)) {
             $content = get_the_excerpt();
         } else if  (is_category()) {
             $content = get_the_content();
         }

Viewing 1 replies (of 1 total)
  • The topic ‘Conditional display of the_excerpt or the_content by category id’ is closed to new replies.