Site logo

Archived topic

Custom style "read more" tag

8 replies · Started by Philippe on January 21, 2015

Viewing posts 1–9 of 9

Give this CSS a try:

.read-more,
.read-more:visited {
    background: none repeat scroll 0 0 #222;
    color: #fff;
    display: table;
    margin-top: 1.5em;
    padding: 10px 20px;
}

.read-more:hover {
      background:#666;
      color:#FFF;
}

Adjust the colors as needed :)

Fantastic :)

Tks so mutch Tom

1. You'll have to add a custom function for this - I suggest using this plugin: https://wordpress.org/plugins/code-snippets/

if ( ! function_exists( 'generate_custom_blog_excerpt_more' ) ) :
	/**
	 * Prints the read more HTML
	 */
	add_filter( 'excerpt_more', 'generate_custom_blog_excerpt_more', 100 );
	add_filter( 'the_content_more_link', 'generate_custom_blog_excerpt_more', 100 );
	function generate_custom_blog_excerpt_more( $more ) {
		$generate_settings = wp_parse_args( 
			get_option( 'generate_blog_settings', array() ), 
			generate_blog_get_defaults() 
		);
		return '<div class="read-more-button"><a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . $generate_settings['read_more'] . '</a></div>';
	}
endif;

Then your CSS can change to this:

.read-more-button {
      margin-top: 1.5em;
}

.read-more,
.read-more:visited {
    background: none repeat scroll 0 0 #222;
    color: #fff;
    display: inline-block;
    padding: 10px 20px;
}

.read-more:hover {
      background:#666;
      color:#FFF;
}

Hope this helps :)

Hi Tom,

This is great, but unlike Philippe, I would like to keep the "..."
How do I add that back into the custom functions?

Not sure how it would look to have ... before a button?

You can add it before this: <div class="read-more-button"> so it looks like: ...<div class="read-more-button">

Worked a treat Tom. Thanks :)

You're welcome :)

This archived topic is closed to new replies.