• I run WordPress v6.5.5 as a MultiSite. I use PHP 8.2.20.
    I have the WordPress MU Sitewide Tags Pages plug-in installed and it has served me well over the years.

    However, since upgrading PHP, I encounter an error with this plug-in enabled. For instance, when I want to write a new blogpost on one of the member sites, I get the following error:

    PHP Warning: Attempt to read property "ID" on null in F:\DirTeam.com\wwwroot\wp-content\plugins\wordpress-mu-sitewide-tags\sitewide-tags.php on line 421

    When the plug-in is removed, this error does not occur, but I lose the functionality of the plug-in.

    Line 421 and beyond read like this:

    $global_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE guid IN (%s,%s)", $post->guid, esc_url( $post->guid ) ) );
    if( $post->post_status != 'publish' && is_object( $global_post ) ) {
        wp_delete_post( $global_post->ID );
    } else {
        if( $global_post->ID != '' ) {
            $post->ID = $global_post->ID; // editing an old post
    
            foreach( array_keys( $global_meta ) as $key )
                delete_post_meta( $global_post->ID, $key );
        } else {
            unset( $post->ID ); // new post
        }
    }
    if( $post->post_status == 'publish' ) {
        $post->ping_status = 'closed';
        $post->comment_status = 'closed';
    
        /* Use the category ID in the post */
            $post->post_category = $category_id;
    
        $p = wp_insert_post( $post );
        foreach( $global_meta as $key => $value )
            if( $value )
                add_post_meta( $p, $key, $value );
    }

    How do I overcome this error?

    The page I need help with: [log in to see the link]

  • You must be logged in to reply to this topic.