read more button even if there is no Excerpt
-
Hi.
I was wondering if it is possible to add a read more button even if the post has no excerpt. I have added custom fields to a particular type of post so all of them have additional information but not necessarily a manual excerpt.
I need all the posts to display the button when the search results are displayed.
Thank you!
Add
<!--more-->tag at the end of each post. This should add a read more button at the end of excerpts eventhough there is no more content.Make sure you’ve selected “Show more button for Manual Excerpt” in Graphene Options –> Display –> Excerpt Display Options
That does not work. I don’t know why
Is there a way of doing it with a function on the child theme functions.php?
something like this
$more_link_text = __( 'Ver más »', 'graphene' );
return '</p><p><a href="'.get_permalink().'">'.$more_link_text.'</a>';maybe conditioned to a particular type of post?
Thanks so much
Please put your code between backtics. I’ve corrected your comment above.
Sorry, I did not know about the backticks, its corrected now
You don’t need to add backtics to each line. Just one at the beginning of the code and one at the end. I’ve corrected it again! 🙂
I have this post type, named “sm-location”
and there are 31500 posts.
I need them all to be listed with a “Continue reading” button
thats why I thought maybe it could be done with a funtion in the child theme that would affect all of these types of post. even if they have no excerpt.
It’s too late here. I’ll get back you tomorrow. Or, someone else may help you now.
Admin
Try this:
<?php
function my_custom_more_button(){
if ( get_post_type() != 'sm-location' || is_singular() ) return;
echo graphene_continue_reading_link();
}
add_action( 'graphene_after_post_content', 'my_custom_more_button' );
?>Thanks! It works great.
But for some reason, even though I disabled the “Show more button for Manual Excerpt”, it shows TWO “continue reading” buttons…for the posts that do have an excerpt
Any idea why?
Viewing 10 posts - 1 through 10 (of 12 total)
- 1
- 2
- You must be logged in to reply to this topic.
