admin管理员组文章数量:1327843
I am trying to understand how to use a custom template file, in this case simply to list all posts. Based on my research, and initial responses to this post, the code looks like this:
<?php
/**
* Template Name: Basic Test
*/
get_header();
if ( have_posts() ) :
while ( have_posts() ) : the_content();
the_title();
endwhile;
else :
_e( 'Sorry, no posts matched your criteria.', 'textdomain' );
endif;
get_sidebar();
get_footer();
?>
When I create a new page that uses this template file, the page displays the header, footer, sidebar, page title, and nothing else. I assume I am missing something, but I don't know what. Neither posts nor the error message are displayed.
I am trying to understand how to use a custom template file, in this case simply to list all posts. Based on my research, and initial responses to this post, the code looks like this:
<?php
/**
* Template Name: Basic Test
*/
get_header();
if ( have_posts() ) :
while ( have_posts() ) : the_content();
the_title();
endwhile;
else :
_e( 'Sorry, no posts matched your criteria.', 'textdomain' );
endif;
get_sidebar();
get_footer();
?>
When I create a new page that uses this template file, the page displays the header, footer, sidebar, page title, and nothing else. I assume I am missing something, but I don't know what. Neither posts nor the error message are displayed.
Share Improve this question edited Aug 1, 2020 at 13:23 Justin Freeman asked Jul 31, 2020 at 10:35 Justin FreemanJustin Freeman 11 bronze badge 3 |1 Answer
Reset to default -2I have seen that there is extra ();
so maybe this syntax error prevent display in front-end please try below code -
<?php
/**
* Template Name: Basic Test
*/
get_header();
if ( have_posts() ) :
while ( have_posts() ) : the_post();
the_title();
endwhile;
else :
_e( 'Sorry, no posts matched your criteria.', 'textdomain' );
endif;
get_sidebar();
get_footer();
?>
本文标签: How to implement template file and the loop
版权声明:本文标题:How to implement template file and the loop 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742216322a2434631.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
the_content();
. But like mozboz says, can you clarify what's not being displayed? – Tony Djukic Commented Jul 31, 2020 at 16:14