admin管理员组文章数量:1192814
I am using HTML5 Blank to make my site. I wanted to style some pages differently than others, and therefore made a page template for them. In this page template I have used this to get the content:
<?php the_content(); ?>
This worked perfectly yesterday. Then I woke up today and now the same pages show this error and no content:
Warning: count(): Parameter must be an array or an object that implements Countable in /home/insitvbt/treningsglad/wp-includes/post-template.php on line 317
Everything else in the page template file loads fine, just not the content. I can't see anything in the logs about any updates happening from yesterday until today, so this perplexes me a bit.
These are the lines around 317 in post-template.php:
// If the requested page doesn't exist.
Line 317 ---> if ( $elements['page'] > count( $elements['pages'] ) ) {
// Give them the highest numbered page that DOES exist.
$elements['page'] = count( $elements['pages'] );
}
I have Googled for about an hour and find many people with the same type of problem, but no apparent solution to my exact case. I have disabled all plugins without that helping at all.
Normal posts and pages with the standard template load fine, just not pages with page templates that worked 24 hours ago with no changes up to this point in time.
Where would I begin to solve this?
I am using HTML5 Blank to make my site. I wanted to style some pages differently than others, and therefore made a page template for them. In this page template I have used this to get the content:
<?php the_content(); ?>
This worked perfectly yesterday. Then I woke up today and now the same pages show this error and no content:
Warning: count(): Parameter must be an array or an object that implements Countable in /home/insitvbt/treningsglad/wp-includes/post-template.php on line 317
Everything else in the page template file loads fine, just not the content. I can't see anything in the logs about any updates happening from yesterday until today, so this perplexes me a bit.
These are the lines around 317 in post-template.php:
// If the requested page doesn't exist.
Line 317 ---> if ( $elements['page'] > count( $elements['pages'] ) ) {
// Give them the highest numbered page that DOES exist.
$elements['page'] = count( $elements['pages'] );
}
I have Googled for about an hour and find many people with the same type of problem, but no apparent solution to my exact case. I have disabled all plugins without that helping at all.
Normal posts and pages with the standard template load fine, just not pages with page templates that worked 24 hours ago with no changes up to this point in time.
Where would I begin to solve this?
Share Improve this question edited Apr 22, 2020 at 7:37 TASan asked Apr 22, 2020 at 7:10 TASanTASan 421 silver badge9 bronze badges 3 |1 Answer
Reset to default 1The problem was that the loop related code had been removed from the template file by a mistake without me knowing. I had to add this back in:
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
and
<?php else: ?>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
<?php endif; ?>
本文标签: errorsPHPwarning in posttemplatephp and no loading content on pages
版权声明:本文标题:errors - PHP-warning in post-template.php and no loading content on pages 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738474278a2088768.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
the_content()
inside the loop? Might be just easier if you can share the full page template code. – Jacob Peattie Commented Apr 22, 2020 at 7:50