In the docs, the parameter to pass the post ID is marked deprecated
.
That means, in order for your custom loop to work, you need to add $recent->the_post()
However, as you pointed out, you can’t do that when you use wp_get_posts
, so I’d suggest modifying the query to be a custom loop:
$args = array( 'post_status' => 'pending');
$recent_posts = new WP_Query( $args );
Then, you should be able to use your code:
See below:
while ( $recent_posts->have_posts()) {
$recent_posts->the_post(); // Add this here to cause the other functions to work without the post ID
echo '<div id="votes"><li id="voteimage"><a href="' . get_permalink() . '" title="' . esc_attr( $recent["post_title"] ) . '">';
echo get_the_post_thumbnail($recent["ID"], 'thumbnail');
echo '</li></a>';
echo '<li class="vote-title"><a href="' . get_permalink() . '" title="Look '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li>';
echo '<li class="vote-desc"><a href="' . get_permalink() . '">' . get_the_excerpt() . '</a> </li>';
echo '</div><br></br>';
}
Also note that get_the_excerpt()
will return un-filtered content. You may want to wrap it in an apply_filters()
like so:
apply_filters('the_content', get_the_excerpt());