- This topic has 12 replies, 3 voices, and was last updated 6 years, 10 months ago by sdanbu.
-
AuthorPosts
-
May 6, 2017 at 8:46 pm #314864sdanbu
All post excerpts are changed to show “…” when the excerpt is cut off. It looks funny because the author did not write …
Is there a way to change the automatic “…” to “[…]”?
May 6, 2017 at 9:14 pm #314872LeoStaffCustomer SupportHi Scott,
This function should work:
add_action( 'after_setup_theme','tu_remove_read_more' ); function tu_remove_read_more() { remove_filter( 'excerpt_more', 'generate_blog_excerpt_more', 99 ); } add_filter( 'excerpt_more', 'tu_blog_excerpt_more', 99 ); function tu_blog_excerpt_more( $more ) { if ( ! function_exists( 'generate_blog_get_defaults' ) ) return; $generate_settings = wp_parse_args( get_option( 'generate_blog_settings', array() ), generate_blog_get_defaults() ); // If empty, return if ( '' == $generate_settings['read_more'] ) return; return ' [...] <a title="' . esc_attr( get_the_title() ) . '" class="read-more" href="'. esc_url( get_permalink( get_the_ID() ) ) . '">' . $generate_settings['read_more'] . '</a>'; }
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
If you don’t have anything entered in Customizer > Blog > Blog Content > Read more label, then try inserting a space.
Let me know.
May 7, 2017 at 12:03 am #314893sdanbuI tried this it didn’t work maybe i did something wrong
I downloaded and installed code snippets plugin
Then I added a new snipped and copied the above (see below)
add_action( ‘after_setup_theme’,’tu_remove_read_more’ );
function tu_remove_read_more() {
remove_filter( ‘excerpt_more’, ‘generate_blog_excerpt_more’, 99 );
}add_filter( ‘excerpt_more’, ‘tu_blog_excerpt_more’, 99 );
function tu_blog_excerpt_more( $more ) {
if ( ! function_exists( ‘generate_blog_get_defaults’ ) )
return;$generate_settings = wp_parse_args(
get_option( ‘generate_blog_settings’, array() ),
generate_blog_get_defaults()
);// If empty, return
if ( ” == $generate_settings[‘read_more’] )
return;return ‘ […] ‘ . $generate_settings[‘read_more’] . ‘‘;
}It didn’t work – nothing changed. Is it because I should do something with my show posts lists?
After that, I also went to customizer to see blog>blog content>readmore and added a space but nothing changed either.
May 7, 2017 at 12:08 am #314894TomLead DeveloperLead DeveloperYou could actually simplify it quite a bit now:
add_filter( 'generate_excerpt_more_output','tu_change_read_more' ); function tu_change_read_more() { return sprintf( ' [...] <a title="%1$s" class="read-more" href="%2$s">Read more</a>', the_title_attribute( 'echo=0' ), esc_url( get_permalink( get_the_ID() ) ) ); }
Make sure the code snippet you added is actually activated as well.
May 7, 2017 at 5:08 am #314938sdanbuI tried creating a snippet and activated it but it still didn’t work.
I tried both snippets including the most recent one:
add_filter( ‘generate_excerpt_more_output’,’tu_change_read_more’ );
function tu_change_read_more() {
return sprintf( ‘ […] Read more‘,
the_title_attribute( ‘echo=0’ ),
esc_url( get_permalink( get_the_ID() ) )
);
}Do I need to edit function.php?
May 7, 2017 at 11:23 am #315032TomLead DeveloperLead DeveloperWhat version of GP are you using?
Can you show me a screenshot of the code snippet page?
May 7, 2017 at 4:52 pm #315144May 7, 2017 at 6:50 pm #315174TomLead DeveloperLead DeveloperAny chance you can show me the full page?
May 7, 2017 at 8:45 pm #315194sdanbuDo you mean like this?
http://tinypic.com/r/j5xwea/9I don’t really know if it’s any different – maybe you meant something else also…
May 7, 2017 at 11:39 pm #315214TomLead DeveloperLead DeveloperStrange.. Is there any way you can send me temporary admin login details?: https://generatepress.com/contact/
May 8, 2017 at 6:12 am #315364sdanbusent thanks
May 8, 2017 at 7:11 pm #315677TomLead DeveloperLead DeveloperAhh you’re using WP Show Posts.
Try this instead:
add_filter( 'wpsp_ellipses','tu_wpsp_ellipses' ); function tu_wpsp_ellipses() { return '[...]'; }
May 16, 2017 at 4:17 pm #318937sdanbuwizardry
-
AuthorPosts
- You must be logged in to reply to this topic.