Skip to content

Instantly share code, notes, and snippets.

@OscarAbadFolgueira
Created September 7, 2018 16:36
Show Gist options
  • Save OscarAbadFolgueira/c8a4fa93e73d80ca905e8b6fe23a38ba to your computer and use it in GitHub Desktop.
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
<?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