Make WordPress Core

Ticket #40796: 40796.patch

File 40796.patch, 1.1 KB (added by smit08, 7 months ago)

Hi @swissspidy, As mentioned in my previous comment, the code line has been updated, and this issue can be resolved using the patch I provided. If we decide to proceed with the fix, we can apply my patch. I would appreciate it if a tester could review and test my patch. Thank you in advance.

  • wp-content/themes/twentyseventeen/inc/template-tags.php

     
    152152        // Only when in Customizer, use a placeholder for an empty panel.
    153153        $show_panel_placeholder = false;
    154154
    155         global $post; // Modify the global post object before setting up post data.
    156         if ( get_theme_mod( 'panel_' . $id ) ) {
    157                 $post = get_post( get_theme_mod( 'panel_' . $id ) );
    158                 setup_postdata( $post );
     155        // Retrieve the post associated with the panel ID.
     156        $panel_post = get_post( get_theme_mod( 'panel_' . $id ) );
     157
     158        if ( $panel_post ) {
     159                setup_postdata( $panel_post );
    159160                set_query_var( 'panel', $id );
    160161
    161                 if ( $post && in_array( $post->post_status, array( 'publish', 'private' ), true ) ) {
     162                if ( in_array( $panel_post->post_status, array( 'publish', 'private' ), true ) ) {
    162163                        get_template_part( 'template-parts/page/content', 'front-page-panels' );
    163164                } elseif ( is_customize_preview() ) {
    164165                        $show_panel_placeholder = true;