Custom text box containing post titles

If you type “WordPress get recent posts” into Google you will see, right at the top of the list, wp_get_recent_posts. Follow that link and you will end up on that function’s “Function Reference” page in the Codex, where you will find, about halfway down, that someone has posted an example that does pretty much exactly what you want to do– create a list of post titles.

<h2>Recent Posts</h2>
<ul>
<?php
    $recent_posts = wp_get_recent_posts();
    foreach( $recent_posts as $recent ){
        echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';
    }
?>
</ul>

It looks like you just registered, so in the future, be aware that you are expected to have researched the problem and made an attempt at solving it before posting a question.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)