Very good to know, thank you.
Now I have another “bug”, the posts IDs are displayed on top of the block…
https://app.box.com/s/ge7tmhhi514dgsva4mpj9vp01ogy4jwx
Here is the code
function HP_show_sticky_post() {
$StickyPST = "";
//créé une nouvelle recherche dans la BDD
$sticky_post = new WP_Query();
//recherche si le post est épinglé
$sticky = get_option('sticky_posts');
//$query = new WP_Query( array( 'post__not_in' => get_option( 'sticky_posts' ) ) );
//arguments
$args = array(
'post__in'=> $sticky,
'post_type'=>'post',
'showposts'=>'1',
'ignore_sticky_posts' => 1,
);
//lancement de la recherche avec les arguments
$sticky_post->query($args);
if ($sticky_post->have_posts()) : while ($sticky_post->have_posts()) : $sticky_post->the_post();
$sp_id = the_ID();
$sp_permalink = get_permalink($sticky_post->post->ID);
$sp_title = get_the_title($sticky_post->post->ID);
$sp_exerpt = get_the_excerpt();
if(has_post_thumbnail($sticky_post->post->ID)) { $sp_thumbnail = get_the_post_thumbnail($sticky_post->post->ID,''); }
$StickyPST .=' <div class="hp_sticky_post">
<a href="'.$sp_permalink.'">
<h2>'.$sp_title.'</h2>
</a>
<div class="sp_content">
<a href="'.$sp_permalink.'">
<div class="sp_thumb">'.$sp_thumbnail.' </div>
</a>
<div class="sp_excerpt">'.$sp_exerpt.'</div>
</div>';
endwhile; endif;
return $StickyPST;
}
add_shortcode("show_sticky_post", "HP_show_sticky_post");
wp_reset_postdata();
[Moderator note: Please, No bumping.