WordPress.org

Ready to get started?Download WordPress

Forums

any way of directly making the "[...]" in excerpts a link? (7 posts)

  1. Skeary
    Member
    Posted 9 years ago #

    I've searched and found some discussions on adding a link after the excerpt, but what about in the excerpt itself? I can't find where the excerpt and the [...] is defined though. Does anybody know?

  2. Kafkaesqui

    Posted 9 years ago #

    "Faked" excerpts (excerpts extracted from post content) are done through the wp_trim_excerpt() function in functions-formatting.php in the wp-includes directory.

  3. Skeary
    Member
    Posted 9 years ago #

    Excellent. thanks.

    so it must be this:
    if (count($words) > $excerpt_length) {
    array_pop($words);
    array_push($words, '[...]');
    $text = implode(' ', $words);
    }
    }
    return $text;

    I tried to make it a link using
    <a href="<?php the_permalink() ?>" rel="bookmark">[...]</a> in the array_push part, but it does not treat the php script as php; so clearly i'm not really sure what i'm doing

  4. Kafkaesqui

    Posted 9 years ago #

    Try this modification:

    $permadots = '[<a href="' . get_permalink($post->ID) . '">...</a>]';
    array_push($words, $permadots);

    Note to newly minted hackers: Back up any source files before editing them, and comment your changes for future reference, i.e.:

    // Skeary: ellipsis now permalink ($permadots)
    $permadots = '<a href="' . get_permalink($post->ID) . '">[...]</a>';
    array_push($words, $permadots);

  5. Skeary
    Member
    Posted 9 years ago #

    works great! thanks a lot.

    good point about the newly minted hackers.. though as i've already not been doing that quite a lot, it might be too late to salvage.

  6. 3stripe
    Member
    Posted 9 years ago #

    interesting, you'd think something like this would be operational by default....

  7. nomad1
    Member
    Posted 9 years ago #

    Thanks. I also wandered how to do that. Works great!

    A related question: How can I change the functions-formatting.php so that images are displayed on the front page (when there is no text in the entry or when the image is placed before the text)? Is this possible? Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.