0

So basically I'm trying to make a list of posts that aren't published yet. (pending) http://streakingpirates.com/mytestpage/ here's my result with the below code so far and as you can see the post titles are showing 3 times per image.

Here's my code:

<ul>
<?php

echo '<ul>';
    $args = array( 'post_status' => 'pending');
    $recent_posts = wp_get_recent_posts ( $args );
    $thumbnails = get_posts($args,'numberposts=5');
    foreach ($thumbnails as $thumbnail) {
     echo '<li><a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
    echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail');
     echo '</a></li>';

foreach( $recent_posts as $recent ){
    echo '<li class="vote-title"><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> '. $recent["the_author"].' </li>';
}

}

echo '</ul>';

?>

</ul>

Pretty much new to php (as of today and minor experiences which were more html related in the past) and just about getting my head around it so any help would be greatly appreciated thanks :)

I also have this page http://streakingpirates.com/pending/ but the reason I'm trying to make it different is I want them listed and closely together in the same content div rather than showing the whole article in huge chunks like the following code does

<?php
$args= array(
    'post_type' => 'post', 
    'post_status' => 'pending'
);
query_posts($args);
?>

but it might have an easier solution

1
  • You are asking two questions here. Please break your question up into two separate questions. One question per post. May 20, 2014 at 9:13

1 Answer 1

0

You are currently having 2 loops, while you only need one. Something like this should work:

<ul>
<?php
    $args = array( 'post_status' => 'pending');
    $recent_posts = wp_get_recent_posts ( $args );

    foreach( $recent_posts as $recent ){
        echo '<li><a href="' . get_permalink( $recent["ID"] ) . '" title="' . esc_attr( $recent["post_title"] ) . '">';
        echo get_the_post_thumbnail($recent["ID"], 'thumbnail');
        echo '</a></li>';
        echo '<li class="vote-title"><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> '. $recent["the_author"].' </li>';
    }
?>

</ul>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.