How to display your latest WordPress posts inside your page
How to display WordPress featured image in HTML page with PHP
1. Do you have a web page in html?
Yes, you have to change the extension of your page to .php
2. Do you have a WordPress blog installed on your server?
Yes
3. You will only need to include the following code in your php page external to the blog:
Show the latest entries
<?php
define('WP_USE_THEMES', false);
require_once($_SERVER['DOCUMENT_ROOT'] . '/blog/wp-blog-header.php');
query_posts('showposts=7');
echo '<ul>';
while (have_posts ()): the_post();
echo "<li><a href='" . get_permalink($post->ID) . "'>";
the_title();
echo '</a></li>';
endwhile;
echo '</ul>';
?>
show tag cloud
<?php
wp_tag_cloud('smallest=8&amp;amp;amp;largest=36&amp;amp;amp;');
?>
show featured image
<?php the_post_thumbnail('medium'); ?>
NOTE:
- With showposts=6 We indicate the number of posts that we want to show.
- With get_permalink($post->ID) we get the URL of each of the articles.
- With the_title(); we get the title of the article.
- wp-blog-header.php (You have to indicate the correct path to your blog)