How to see the most recent entries of my blog on the main page?

0

What happens is that I have a website in which I have a blog in wordpress, and what I want to do is that the most recent entries are displayed on the home page of my site, but I do not know how to do this , I hope you can help me.

    
asked by OrlandoVC 13.03.2017 в 16:15
source

1 answer

1

If your main page is not Wordpress, to integrate the last posts of your blog you must know the location of the wp-blog-header.php file that exists between the files of your Wordpress. Then, you have to include this in the homepage of your site:

<?php
// Incluye el archivo "wp-blog-header.php"
require_once('/path/a/wp-blog-header.php');
// Obtiene las 10 últimas entradas del blog, ordenadas por título
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
// Recorre las entradas para mostrarlas en una lista
foreach ($posts as $post): 
    setup_postdata($post);
    the_date(); // muestra la fecha
    the_title(); // muestra el título
    the_excerpt(); // muestra el resumen 
endforeach;

The above is taken from the Wordpress Codex, where there are other examples: Integrating WordPress with Your Website .

    
answered by 14.03.2017 в 02:07