我读到了这篇文章(https://codex.wordpress.org/Class_Reference/WP_Query) 并尝试运行标准循环,但我无法收到任何结果。我的代码是:
<?php get_header();
/*
Template Name: Page teste
*/
?>
<?php
echo "ola";
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo \'<ul>\';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo \'<li>\' . get_the_title() . \'</li>\';
}
echo \'</ul>\';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
get_footer();
?>
此代码位于文件调用“page test.php”中。这是我的WordPress上的页面模板。