TUTORIAL

Add a link to automatic excerpt

In this short tutorial I’ll show you how to add a link to an automatic excerpt of your posts. If you don’t like to read much, just skip ahead to the code below. I like to ramble sometimes.

Introduction

What is an excerpt?

The WP definition says that the excerpt is an optional summary or description of a post; in short, a post summary. Thats what you see under your posts in your blog page. Normally the automatic excerpt is 55 words long and in the Pinboard theme ends with three dots “…”.

And what is an automatic excerpt?

There are two different ways for an excerpt to be shown. The first one is the standard one and is called “automatic” because the function to display the excerpt takes your copy and extracts the first 55 words automatically. The second way is that you write an excerpt by yourself which you can do when editing or creating a new post (and posts only) in a dedicated “Excerpt” box.

The goal

I wrote this tutorial because I didn’t like the automatic excerpt to end with three simple dots that you can’t even click. It is common sense that whatever you want to be the end of your excerpt, it should be clickable. Therefore I changed the code in the function of this theme.

It’s small an easy change.

  • Open your functions.php file of the Pinboard theme.
  • Search the function “pinboard_excerpt_more($more)”
  • Change the one line
  • Save the changed function.php file

Here is what it looks like before (original functions.php):

function pinboard_excerpt_more($more) {
return ' …';
}
endif;

and here is what I changed it to:

function pinboard_excerpt_more($more) {
return ' <a href=" '. get_permalink($post->ID) . ' "> &#8230;more</a>';
}
endif;

As you can easily see only the return value has changed.

The result

Instead of having three dots “…” which you can’t click you will now have “…more” and clickable.

Of course you can change the “…more” in whatever you like, even the old fashioned brackets [...] are possible.

I hope you like the tutorial and it was helpful for you.

Cheers,
Alexander

  1. coencoen11-06-2012

    Hi Alexander,
    Where can I find the dedicated “Excerpt” box? And why can’t I use the “Insert More Tag” [Alt + Shit + T]?

    Adventurous greetings,
    Coen

    • AlexanderAlexander11-06-2012

      Hi Coen, click screen options, and enable them. The box is disabled by default.

      You can use the “Insert More Tag” but you have to insert it manually in each post and it still didn’t give you anything clickable in the excerpt.

  2. oh, no! crisis! i did this, and got this result when i load the page:

    Parse error: syntax error, unexpected T_STRING in /home/content/83/9866683/html/wp-content/themes/pinboard/functions.php on line 1576

    and, of course, i got overly confident and didn’t save the original coding, and copying and pasting your original code doesn’t resolve the issue.

    if you know of a quick fix, please let me know. i appreciate it!

  3. update, alexander! sorry… i panicked too soon. i was able to get into my ftp deal through my hosting admin and switch it back there. i’ll start there next time. this is complicated stuff!

    • AlexanderAlexander11-12-2012

      It’s not rocket sience but I’m happy your back again :)

  4. LinnLinn11-18-2012

    Hi Alexander! Thank you for your great tutorials, they have been a lot of help! However i can’t seem to get this right. When i change the code to the lines you posted here i get the same error as Caroline Duke so i have to go back to the original function.php. Do you know why i can’t get his to work? Is there a ‘ or ; missing somewhere? Or could you perhaps post your updated function.php as a txt document so i can copy it from there instead? Would be very very grateful for your help!
    Cheers
    Linn

    • AlexanderAlexander11-18-2012

      Linn, the code is working fine. Most of the time errors occure by copy & paste incorrect without knowledge of the user. Therefore I changed the font to something hazard-free. Maybe you want to give it another try now?

      Cheers,
      Alexander

  5. AlexanderAlexander12-28-2012

    I’m no longer with the Pinboard theme.

    The tutorials are still accessible but no longer supported.

    /closed