How to display Wordpress "recent posts" on an external html page

Asked

Viewed 1,224 times

0

I made a site using HTML & CSS and created the blog in CMS Wordpress.

I have no experience with programming and now I need to search the database the last 3 recent blog posts I created.

Does anyone have any suggestions where I should start?

1 answer

1


Friend, I could not intender very well, next puts more information as Theme used etc, well I imagine you need to add a new page to Wordpress it works with templates, inside the folder of your Theme usually stay at the root these templates, take a copy and inside you can add the Wordpress code that brings you the latest posts vide:

https://codex.wordpress.org/Function_Reference/wp_get_recent_posts

inside the Wordpress Codex has a lot of cool material.

in your case it would be something like:

first create a template: https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

and inside the page the code that contains the last posts:

<h2>Titulo Ultimo 3 posts</h2>
<ul>
<?php
    $args = array( 'numberposts' => '3' ); // aqui troca o numero pela quantidade de posts que queira trazer, e caso queira customizar mais o resultado vira aqui dentro do array () veja a pagina.
    $recent_posts = wp_get_recent_posts( $args );
    foreach( $recent_posts as $recent ){
        echo '<li><a href="' . get_permalink($recent["ID"]) . '">' .           $recent["post_title"].'</a> </li> ';
    }
 ?>
</ul>
  • Thanks for the reply Joel, I will try to create the template.

  • @Joel-Martins, how do I do this with javascript/jquery? Where do I want to display not accept php.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.