I'm trying to add a button to every post excerpt. But I get the button without href:
function new_excerpt_more( $more ) {
global $post;
return "<p><a href='" .get_permalink( $post->ID ) ."' class='btn' >Read more</a></p>";
}
add_filter('excerpt_more', 'new_excerpt_more');
The problem only occurs when I'm showing the excerpts with a shortcode command within the content:
function show_last_articles() {
$args = array( 'posts_per_page' => 3, 'category_name' => 'xyz');
$lastposts = get_posts( $args );
foreach ( $lastposts as $post ):
setup_postdata( $post );
$return = "<div class='excerpts'>";
$return .= "<h2><a href='" .get_the_permalink( $post->ID ) ."'>" .get_the_title( $post->ID ) ."</a></h2>";
$return .= "<div>" .get_the_excerpt( $post->ID ) ."</div>";
$return .= "</div>";
endforeach;
wp_reset_postdata();
return $return;
}
add_shortcode( 'last_articles', 'show_last_articles');
Whats wrong?