Problem with the excerpt (4 posts)

  1. Filip
    Posted 5 years ago #

    hello, got this little problem that drives me nutz', and hope you can give me a tip or something...

    so... i want to use the excerpt on my category pages... so... when i have:

    <?php the_content(); ?>

    working great... it displays the content...

    but when i change it to

    <?php the_excerpt(); ?>

    nothing shows up as the content! All i got is the title, and other elements... but no article content ...

    do you have any suggestions? I just can't figure it out... I would really apreciate it

    Thank you!

  2. borantula
    Posted 5 years ago #

    can you give more clue
    write the loop part of the category page maybe

  3. Chip Bennett
    Theme Review Admin
    Posted 5 years ago #

    Pages don't natively support excerpts. You need to add support for excerpts to Pages, if you want to use the_excerpt().

    Try this, in functions.php:

    add_post_type_support( 'page', 'excerpt' );
  4. Filip
    Posted 5 years ago #

    hello, thank you for your answer... taht didn't work either... i don't know why... i managed to resolve this issue with copying a fragment of better excerpt plugin in functions.php:

    add_option("better_excerpt_length", '250', '', 'yes');
    add_option("better_excerpt_ellipsis", '...', '', 'yes');
    add_option("better_excerpt_before_text", '<p>', '', 'yes');
    add_option("better_excerpt_after_text", '</p>', '', 'yes');
    add_option("better_excerpt_keep_line_breaks", '0', '', 'yes'); 
    function get_options(){
     $options = array();
     $options['length'] = get_option(better_excerpt_length);
     $options['ellipsis'] = get_option(better_excerpt_ellipsis);
     $options['before_text'] = get_option(better_excerpt_before_text);
     $options['after_text'] = get_option(better_excerpt_after_text);
    return $options;
    function better_excerpt($length, $ellipsis, $before_text, $after_text) {
    $permalink = get_permalink($post->ID);
    $text = get_the_content();
    $text = preg_replace(" (\[.*?\])",'',$text);
     if ($keep_line_breaks == 0) {
    $text = strip_tags($text);
     else {
    $text = strip_tags($text, '<p><br>');
    $text = substr($text, 0, $length);
    $text = substr($text, 0, strripos($text, " "));
    $text = trim(preg_replace( '/\s+/', ' ', $text));
    $text = stripslashes($before_text).$text.$ellipsis;
    $text .=stripslashes($after_text);
    return $text;
    function get_better_excerpt() {
    $options = get_options();
    return better_excerpt($length, $ellipsis, $before_text, $after_text);
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'get_better_excerpt');

    and now it works...

    Thank you again!

Topic Closed

This topic has been closed to new replies.

About this Topic