I think the problem lies with functions like the_title()
vs get_the_title()
This seem to work:
if (!function_exists('footer_get_latest_post')) {
function footer_get_latest_post() {
$footerPost="";
$args = array('posts_per_page' => 1 );
$recent_posts = new WP_Query($args);
while( $recent_posts->have_posts() ) {
$recent_posts->the_post();
$footerPost="<div class="footer-post-thumb">" . get_the_post_thumbnail('thumbnail') . '</div>';
$footerPost .= '<div class="footer-post-content"><h3>' . get_the_title() . '</h3>';
$footerPost .= get_the_content() . '</div>';
}
wp_reset_query();
return $footerPost;
}
}
add_shortcode('FooterLatestPost', 'footer_get_latest_post');
Without the get
part, the functions echo their results “in situ.”