last day (15 days later) » 

7:46 PM
0
Q: The excerpt doesn't add Read more

TrufaI am confused about the behaviour of the_excerpt() and get_the_excerpt(). My objective is to have a manual excerpt and display a continue reading. I went through this article, and apparently the_excerpt() is not meant for that. So I'm trying get_the_excerpt() instead, and I still don't get th...

 
@sakibmoon I am modifying directly the code of the theme. I don't think it's the child of any other theme.
 
Add low priority to excerpt_more filter as I mentioned in my previous post. Then it will override your themes default one and give the result that you want.
@PieterGoosen You got me worrying there for a minute. Make sense now. But I will advise against using $post->$post_excerpt directly. It's kinda stiff in my opinion.
 
@sakibmoon is low priority a high number? Of which function do you mean? Right now I have this and in my contents.php I have the_excerpt(), I have tried most combinations and nothing seems to work, what should it look like?
 
I'm off to bed now, the excerpt_more link does not work on manual excerpts. Not when using $post->post_excerpt,, the_excerpt() or get_the_excerpt(). You'll have to manually add the read more text where you need it
 
@PieterGoosen ok, thanks, but is there another function I could use? I'm not hellbent on this function, or my only option is to add it manually?
 
8:07 PM
@Trufa I believe @PieterGoosen is right about excerpt_more filter. Change that to get_the_excerpt and return after concatenating with $more.
 
I wonder if it's related to the fact that your excerpt_length filter returns 1, ie, one word. If you crank that up to, say, 20 or so, does it start to work?
 
@PatJ I just put it to 1 because it was not working with 55, tried several number, all things remaining equal, it doesn't make it appear.
 
// Add more-link text to excerpt
function new_excerpt_more( $more ) {
return $more. '... <a class="more-link" href="'. get_permalink( get_the_ID() ) . '">' . __('Continue Reading', 'baskerville') . ' &rarr;</a>';
}
add_filter( 'get_the_excerpt', 'new_excerpt_more' );
Try this code. It changes the excerpt. Should work.
 
@sakibmoon I don't get exactly what you mean, I'm not doing echo get_the_excerpt() and I see the excerpt. I don't get what you mean by: Change that to get_the_excerpt and return after concatenating with $more.
something like this? return $more . '... <a class="more-link" href="'. get_permalink( get_the_ID() ) . '">' . __('Continue Reading', 'baskerville') . ' &rarr;</a>';
Or did I misunderstood you?
 
Yes. Like that.
I have posted the code just before this.
 
8:21 PM
@sakibmoon wow! Awesome man!
Thanks a lot!
Please post it as an answer!
I am truly dissapointed in WP though.
It's pretty amazing the amount of effort this took.
given the ease of the task at hand.
 
@Trufa Glad I could help. I will add it as an answer soon.
It's not the fault of WP though.
Once you have worked a little more with WP, it will come easy.
Try to read the codex, it explains lots of stuff and what you should do.
@Trufa I added the answer.
I suggest you to read the answer and this article rarst.net/wordpress/wordpress-excerpt-teaser again for better understanding the whole situation.
 
@sakibmoon I have worked with wordpress and I can do most stuff without getting stuck but there's always something every now and then that get's in my way in a ridiculously annoying way :)
Also I read the article, but couldn't figure out where the the answer to my particular problem lies.
The article also seems to show to me that that is NOT a clearly defined function with an predictable behaviour
the in codex are incredibly confusing
I don't want to sound like I hate wordpress or anything
I know there's a lot of unnecessary bashing
and some familiarity goes a long way, but still, some parts seem to be just way too complex.
 
8:40 PM
@Trufa There are lots of filters to get confused. I give you that
One rule of thumb that you can follow is to follow all the filter/action references in the codex and search with the thing that you are looking for.
In your case in was excerpt.
So open Filter reference page
And search the filters containing excerpt.
If you read the first paragraphs of these filters and example if available, you will know whether that's what you need.
 
@sakibmoon Ok, I went through all that, but neither this: codex.wordpress.org/Function_Reference/…
nor the filters page
seem to guide me toward the correct answer
that is appending $more
 
90% of time this help me to find the right filter.
You will find get_the_excerpt in filter page too.
You may have to look through 10-20 filters, but you will find the right filters.
 
@sakibmoon but not this time or am I missing something (I'm not trying to ba a smartass :)) I'm geniunly curios
 
Then search with excerpt.
There is 14 filters containing excerpt
 
@sakibmoon yeah
I had gotten to that filter
but I still don't get how was I supposed to know
from that filter
maybe I'm just tired :)
 
8:47 PM
The first filter is excerpt_edit_pre
Open that page
Read what it does.
Is this what you need?
If no, try the next filter containing the term excerpt.
Maybe my words are confusing you more.
If that's the case, don't worry.
The link you have given is not the same link I have given.
I mean the filter reference page that list all the filters.
Anyway, give it a rest for today.
 
@sakibmoon thanks for all the help
I'm glad it's solved anyway
:)
 

last day (15 days later) »