Muffox Muffox
asked 5 years ago

Hi, I’m using DW Timeline (free version). This theme doesn’t support default widget. May I know how to add recent post to every post page?

muffox
replied 5 years ago

I try adding this code manually in every post I did but it won’t run the code.

<?php $recent_posts = wp_get_recent_posts();
foreach( $recent_posts as $recent ){
if($recent[‘post_status’]=="publish"){
if ( has_post_thumbnail($recent["ID"])) {
echo ‘<li style="padding:5px;border-bottom:1px solid goldenrod;">
<a href="’ . get_permalink($recent["ID"]) . ‘" title="Look ‘.esc_attr($recent["post_title"]).’" >’ . get_the_post_thumbnail($recent["ID"], ‘thumbnail’). $recent["post_title"].’ ‘;
}else{
echo ‘<li style="padding:5px;border-bottom:1px solid goldenrod;">
<a href="’ . get_permalink($recent["ID"]) . ‘" title="Look ‘.esc_attr($recent["post_title"]).’" >’ . $recent["post_title"].’ ‘;
}
}
}
?>

muffox
replied 5 years ago

Problem solved. I download and using this plugin -> https://wordpress.org/plugins/shortcode-exec-php/

Powered by DW Question & Answer Pro