Genesis Adding a Read More Button to Excerpts on Archives


If you find this free website useful – why don’t you support this with a donation? It is easy…. read more ….

With Genesis when you select archives to display excerpts, you don’t get a read more link or button, just some dots.

Although you can click on the title, this isn’t intuitive or user friendly.

The following code snippet can handle this

add_filter( 'the_excerpt', 'bw_excerpt_read_more_link' );
function bw_excerpt_read_more_link( $output ) {
    if( 'post' === get_post_type() ) {

        $btn="<div class ='read-more'>";
        $btn.="<a class='bw-link' href='".get_permalink( )."'><button>".__('read more',maw)."</button></a>";
	$btn.="</div>";
        return $output . $btn;
    } else {
			return $output;
		}
}

 

Note the ‘post’===  is to restrict it just to posts, this stops you accidentally adding read more to custom posts types (although you might want that all depending on your design )

 

, ,

Leave a Reply

Your email address will not be published.