- This topic has 3 replies, 2 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
March 4, 2019 at 12:59 am #828037
Martin
Hello. This is my first post here as I find so much useful answers I’ve not needed to post before.
I was researching how to make nicer ‘read more’ links and links on blog post titles – without the yukky /#more- bit on the end of the URL and found some useful PHP snippets within the answers in this forum. however, after installing GPP, the snippets gave me a WSD (the dreaded White Screen of Death).
Although I hadn’t got to exactly what I wanted with the ‘more’ links, this is the code I was using (written by Tom):
add_action( ‘after_setup_theme’,’tu_remove_read_more’ );
function tu_remove_read_more() {
remove_filter( ‘excerpt_more’, ‘generate_blog_excerpt_more’, 99 );
remove_filter( ‘the_content_more_link’, ‘generate_blog_content_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’] . ‘‘;
}add_filter( ‘the_content_more_link’, ‘tu_blog_content_more’, 99 );
function generate_blog_content_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;$more_jump = apply_filters( ‘generate_more_jump’,’#more-‘ . get_the_ID() );
return ‘<p class=”read-more-container”>‘ . $generate_settings[‘read_more’] . ‘</p>’;
}After removing bits of the code, it turns out the last section is the bit causing the WSD.When I remove
add_filter( ‘the_content_more_link’, ‘tu_blog_content_more’, 99 );
function generate_blog_content_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;$more_jump = apply_filters( ‘generate_more_jump’,’#more-‘ . get_the_ID() );
return ‘<p class=”read-more-container”>‘ . $generate_settings[‘read_more’] . ‘</p>’;
}the WSD is no more…
But now my read more link is as it was before, containing the yukky /#more-nn
Anyone managed to create a nice ‘read more’ link in GPP?
Thanks.
Martin
GP Premium 1.7.8March 4, 2019 at 9:37 am #828575Tom
Lead DeveloperLead DeveloperHi there,
It’s actually quite easy to remove the #more part, you just need to do this:
add_filter( 'generate_more_jump', '__return_empty_string' );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 4, 2019 at 9:48 am #828597Martin
Wow that is much easier.
How can I change ‘Read more’ to ‘Read the full article’?
Thanks Tom.
March 4, 2019 at 9:51 am #828603Tom
Lead DeveloperLead DeveloperYou can do that in Customize > Layout > Blog 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.