Support » Fixing WordPress » Can the_excerpt grab post title?

  • Hi – I want the_excert tag ti function as a read more tag, but grab the post title Is this possible? I need to set up for a client who doesn’t want to have to fuss with the more tag each time he posts. (http://www.robertskrob.com).

    I thought this would work:

    <?php the_excerpt("...continue reading " . get_the_title('', '', false)); ?>

    Can someone tell me what I can do. Pls. note, I am not a php whizz, so need somewhat straight forward info.

Viewing 8 replies - 1 through 8 (of 8 total)
  • the_excerpt() doesn’t do “read more” – you would have to create a link yourself, like this:

    <?php the_excerpt(); ?>
    <a href="<?php the_permalink(); ?>">continue reading...</a>

    Hope that helps!

    He, I didn’t know that. Going to try immediately!

    [edit], hmmm. The […] are built in somewhere so they still appear and the “continue reading…” gets another font, so I’ll have to have a look at my stylesheet. It’s better than nothing though.

    (note: I use the Excerpt Editor plugin that can make excerpt everywhere but on the search results page.)

    Hi – Yes, definitely closer to what I was shooting for. Same issue as Gangleri though: would love to get rid of the […]. Any suggestions? And still wondering if there a way to get the

      continue reading…

    , to pull the post title though? I am going to experiment abit but if anyone knows this already, let me know.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    The wp_trim_excerpt function creates the excerpt from the original content unless you have a custom excerpt defined for that post. It is what adds the […] text.

    OK, just seeking clarification: If I don’t want to use a custom excerpt can I edit the wp_trim_excerpt to not use […]? If so, where do I find the wp_trim_excerpt tag?

    wp_trim_excerpt() is defined in wp-includes/formatting.php, if you want to start hacking things off it 😉 (commenting out line 857 will do the trick without causing any harm, I think).

    To pull the title use _the_title(), like this:

    <?php the_excerpt(); ?>
    <a href="<?php the_permalink(); ?>">Read more about <?php the_title(); ?></a>

    Brilliant! I now have the title showing.

    I found wp_trim_excerpt on line 821 in my wp-includes/formatting.php. The line I was interested in looks like this:
    array_push($words, ‘[…]’);`

    Commenting out worked but then it shoved the Share this right up against the text. So I experimented. You can edit the anything inside the [] on line 821. I changed mine to read ‘ […use link below to read more] ‘.

    See http://www.robertskrob.com

    Thanks to SteveSmith1983!

    Ah, yes – that’s the line I was referring to. I’m glad you’ve got it how you want it! Happy to help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Can the_excerpt grab post title?’ is closed to new replies.