Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #18408, comment 33


Ignore:
Timestamp:
02/26/2021 09:29:51 PM (4 years ago)
Author:
smerriman
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #18408, comment 33

    initial v1  
    33I've recently discovered, however, that it is not just the WordPress admin that is affected by the call. If completely ordinary theme code runs a custom loop and calls, for example, `the_excerpt` (which is empty, and thus processes the full content in order to generate an automatic one), the `$post` variable is also broken as it is reset to the incorrect value.
    44
    5 Is the true situation here that there is no admin bug at all - and indeed it is *incorrect* for any shortcode or dynamic block to use `wp_reset_postdata` in the first place? (With the solution by eg Bill Erickson - save the `$post` variable and restore it afterwards - the correct coding method?)
     5Is the true situation here that there is no admin bug at all - and indeed it is *incorrect* for any shortcode, dynamic block, or custom code in the admin, to use `wp_reset_postdata` in the first place? (With the solution by eg Bill Erickson - save the `$post` variable and restore it afterwards - the correct coding method?)