-1

I added two text boxes to my home page on a wordpress site and I need to display recent posts titles only. What line of code should i add to do that ?

Here is the code I used to create the boxes:

<p> 
<div class="zedity-editor zedity-notheme" id="zed_fbnvrcpt" style="position: relative; width: 1000px; height: 200px; overflow: hidden;">
<div class="zedity-box zedity-box-Text zedity-edited" style="position: absolute; left: 1px; top: 0px; width: 559px; height: 109px; z-index: 12; display: table; table-layout: fixed; background-color: rgba(242,242,242,1);" data-boxtype="Text">
<div class="zedity-content" style="width: 100%; height: 100%; color: black; font-size: 14px; line-height: 17px; font-family: Arial,Helvetica,sans-serif; display: table-cell; overflow: hidden;">
<p style="margin: 0px; color: black; font-size: 14px; line-height: 17px; font-family: Arial, Helvetica, sans-serif;">Latest News</p>
</div>
<div class="zedity-box zedity-box-Text zedity-edited" style="position: absolute; left: 735px; top: 0px; width: 266px; height: 103px; z-index: 14; display: table; table-layout: fixed; background-color: rgba(110,110,110,1);" data-boxtype="Text">
<div class="zedity-content" style="width: 100%; height: 100%; color: black; font-size: 14px; line-height: 17px; font-family: Arial,Helvetica,sans-serif; display: table-cell; overflow: hidden;">
<p style="margin: 0px; color: black; font-size: 14px; line-height: 17px; font-family: Arial, Helvetica, sans-serif;">Our Clients</p>

</div>
</div>
</div>
</div>

</p> 

1 Answer 1

0

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.

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.