Archived topic
Custom CSS is not working for Read More text
3 replies · Started by Pintu on January 14, 2022
Hi, I've added the custom php for showing the 'Read More' text for custom excerpt in the entry meta section. But my custom CSS is not working for the 'read more' text. I am using `.read-more {
margin-top: 5%;
float: right;
}` for aligning the Read More text but it is not working. However, the CSS is working fine when I am not adding custom excerpts. Please help as I want to apply the CSS to all the Read more text.
Hi Pintu,
I only see one post on your site and the CSS is working properly:
https://www.screencast.com/t/nj6mBjPIm
Let me know if I miss anything :)
Hi, Ying I've added the class="read-more" to the PHP code `add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;
if ( has_excerpt() ) {
$output = sprintf( '%1$s <a href="%2$s">%3$s</a>',
$excerpt,
get_permalink(),
__( 'Read more', 'generatepress' )
);
}
return $output;
}`
Now the code is `add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;
if ( has_excerpt() ) {
$output = sprintf( '%1$s <a class="read-more" href="%2$s">%3$s</a>',
$excerpt,
get_permalink(),
__( 'Read More →', 'generatepress' )
);
}
return $output;
}
`
That's why CSS is working fine now. However, I am not a coder, By fluke, I added the code. Would please verify the later PHP and let me know if I did it right or not. Or something needs to change. Thanks
The code looks good to me :)