• Hi there, i’m making my own theme and i have a little problem with one function.

    I just want to show the last 5 post (publish post), without taking in count the category. So when the visitor goes to a category at the sidebar could see the last X (could be 5 or 10) last post published.

    To make that i’m using the function wp_get_recent_posts but there is a problem apparently because doesnt work. It crash when try to load the file sidebar.php with that function. And i know that the problem is wp_get_recent_posts because if i use a loop with query_post works fine (but i dont want to use this function!).

    I paste here the code, its almost the same that it s in the Codex page.

    <ul id="LastPostList">
    <?php
    $args = array(
        'numberposts' => 5,
        'orderby' => 'post_date',
        'order' => 'DESC',
        'post_type' => 'post',
        'post_status' => 'publish',
        'suppress_filters' => true );
    
        $recent_posts = wp_get_recent_posts( $args, $output = ARRAY_A );
        foreach ($recent_posts as $recent)
        {
        	?>
    	<li class="LastPost"><a href="<?php get_permalink({$recent['ID']}) ?>" title="<?php esc_attr({$recent['post_title']})?>" ><?=$recent["post_title"]?></a></li>
        	<?php
        }
    ?>
    
    </ul>

    Maybe there is something that i cant see… i also try to enable the debug option but didnt shows anything, and the server error file nether.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_get_recent_posts’ is closed to new replies.