Created
September 7, 2018 16:36
-
-
Save OscarAbadFolgueira/c8a4fa93e73d80ca905e8b6fe23a38ba to your computer and use it in GitHub Desktop.
Consulta básica y sencilla para mostrar los posts en una página de WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Argumentos de la consulta | |
$args = array( | |
'post_type' => 'post', | |
); | |
//Consulta basica de entradas | |
$query = new WP_Query( $args ); | |
if ( $query->have_posts() ){ | |
echo '<ul>'; | |
while ( $query->have_posts()) { | |
$query->the_post(); | |
echo '<li>' . get_the_title() . '</li>'; | |
} | |
echo '</ul>'; | |
wp_reset_postdata(); | |
} else { | |
echo "Parece que no hay nada"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment