admin管理员组文章数量:1313121
I'm Starting a WordPress website and I'm having a problem with some of my posts.
This issue is only affecting 2 out of 4 articles and after investigating I cannot think on a reason for that.
This error message appears right below comments section:
Notice: Undefined offset: 0 in /home/***/public_html/wp-includes/class-wp-query.php on line 3152
When I search for that line, I find this function:
I have search for this function in my WordPress code and I only found a few matches:
grep -r rewind_posts *
wp-content/themes/magazine/themify/themify-wp-filters.php: rewind_posts();
wp-includes/class-wp-query.php: $this->rewind_posts();
wp-includes/class-wp-query.php: public function rewind_posts() {
wp-includes/feed-rdf.php:<?php rewind_posts(); while (have_posts()): the_post(); ?>
wp-includes/query.php:function rewind_posts() {
wp-includes/query.php: $wp_query->rewind_posts();
Regarding these results, there are two different implementations of this rewind_post
function in query.php
and class-wp-query.php
.
There are only two places where this function is invoked. I focus on the one related to the theme that is being used, themify-wp-filters.php
, It is called from this function: function themify_404_template
This does not say a lot, because I'm not viewing a 404 page.
I'm currently using Super Socializer plugin but I have not enabled the social commenting feature.
Any ideas?
I'm Starting a WordPress website and I'm having a problem with some of my posts.
This issue is only affecting 2 out of 4 articles and after investigating I cannot think on a reason for that.
This error message appears right below comments section:
Notice: Undefined offset: 0 in /home/***/public_html/wp-includes/class-wp-query.php on line 3152
When I search for that line, I find this function:
I have search for this function in my WordPress code and I only found a few matches:
grep -r rewind_posts *
wp-content/themes/magazine/themify/themify-wp-filters.php: rewind_posts();
wp-includes/class-wp-query.php: $this->rewind_posts();
wp-includes/class-wp-query.php: public function rewind_posts() {
wp-includes/feed-rdf.php:<?php rewind_posts(); while (have_posts()): the_post(); ?>
wp-includes/query.php:function rewind_posts() {
wp-includes/query.php: $wp_query->rewind_posts();
Regarding these results, there are two different implementations of this rewind_post
function in query.php
and class-wp-query.php
.
There are only two places where this function is invoked. I focus on the one related to the theme that is being used, themify-wp-filters.php
, It is called from this function: function themify_404_template
This does not say a lot, because I'm not viewing a 404 page.
I'm currently using Super Socializer plugin but I have not enabled the social commenting feature.
Any ideas?
Share Improve this question edited Jan 29, 2017 at 20:09 Arsalan Mithani 5534 silver badges15 bronze badges asked Jan 29, 2017 at 15:58 WarioNeilaWarioNeila 1131 gold badge1 silver badge3 bronze badges 3 |5 Answers
Reset to default 2You're looking in WordPress core files for the cause of the PHP notice, which is a waste of time, as 1) I doubt you've found a new bug in WordPress, and 2) you don't want to modify WordPress core files to fix a theme or plugin issue, and 3) the error is caused by a theme or plugin and not WordPress core, but shows up in the PHP notice as pointing to core files.
And besides all that, it's a PHP notice. Not an error, not a fatal error, but a notice. All that means is "hey, look at me, you might want to fix me at some point, but I'm not an error." Read https://stackoverflow/questions/4624474/php-difference-between-notice-and-warning
NOTICE: It is a message for saying what you should do and what you should not do.
WARNING: It occurs at run time.But it do not interrupt Code execution.
ERROR: It also occurs at run time, but program execution is not continued it terminates.
So check in wp-config.php and turn off debug so you don't see the notices https://codex.wordpress/Debugging_in_WordPress Or check in php.ini of your hosting account; see https://stackoverflow/questions/1053424/how-do-i-get-php-errors-to-display
To more effectively find the cause of an PHP error or notice, use Debug as linked above. But the simplest thing to do is deactivate all plugins and reactivate until you find the one that throws the notice. Then ask the plugin for help or look in their forums. Or, if a plugin is not the cause, switch to the default WordPress theme and see if the notice is in the error logs recorded by wp_debug.
I recently provided some analysis for the rewind_posts
function.
>grep -r rewind_posts *
wp-content/themes/magazine/themify/themify-wp-filters.php: rewind_posts();
wp-includes/class-wp-query.php: $this->rewind_posts();
wp-includes/class-wp-query.php: public function rewind_posts() {
wp-includes/feed-rdf.php:<?php rewind_posts(); while (have_posts()): the_post(); ?>
wp-includes/query.php:function rewind_posts() {
wp-includes/query.php: $wp_query->rewind_posts();
Most likely the problem is not in the WordPress core, since WordPress superior engineers would not allow for such problems to occur.
From the experience, the theme developers may forget sometimes to be clan the code so you may expect the problem in :
wp-content/themes/magazine/themify/themify-wp-filters.php:
Using the rewind_posts
without checking for some conditions with if()
.
The theme should have this checkers depending what will try to rewind.
I don't have the code so I cannot say more. You may send this problem to the theme support.
For me, the solution was, calling the_post()
before calling the_content()
.
I encountered the same notice and the cause was due to using wordpress while(have_posts)
inside a single-{name}.php file.
And the notice disappeared after removing the loop.
For removing the script, you must configure the wp-config.php as defined below.
define( 'WP_DEBUG', false );
本文标签: wp queryHow can I fix quotNotice Undefined offset 0quot
版权声明:本文标题:wp query - How can I fix: "Notice: Undefined offset: 0"? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741911430a2404467.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
NOTICE
message has disappeared. So, it is definitely a theme issue. – WarioNeila Commented Jan 29, 2017 at 21:53