[wp-trac] [WordPress Trac] #49895: PHP Warning: count(): Parameter must be an array or an object that implements Countable

WordPress Trac noreply at wordpress.org
Tue Apr 14 03:37:29 UTC 2020


#49895: PHP Warning:  count(): Parameter must be an array or an object that
implements Countable
-------------------------------+------------------------
 Reporter:  jbx                |       Owner:  (none)
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:  5.4
 Severity:  minor              |  Resolution:  duplicate
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------

Comment (by Otto42):

 Replying to [comment:4 jbx]:
 > But I checked their template php file, and they have the `have_posts()`
 check, so I can't figure what could be the issue.

 This is still a duplicate of the other ticket. The existence of a
 `have_posts()` check does not a proper Loop make.

 "The Loop" specifically exists when `the_post()` is called. This sets up
 the various globals. Without such a call, then the globals aren't set, and
 so you are calling `the_content()` outside of a proper Loop.

 Putting the results of `get_post()` into a `global $post` isn't good
 enough to make a Loop.

 In any case, being tracked in the other ticket.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49895#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list