Custom theme on multisite has issues with standard loop output
-
I am experiencing the following error output when using the standard loop on page.php and single.php on a multisite-based WordPress installation. The loops are the same for both template types, with the loaded content template the only difference.
I have added the
$page = get_queried_object()
to my page.php template file and dumped the output usingvar_dump( $page )
. The WP_Post object is displaying the correct page object data for each page visited on the multisite. It looks like the data can be retrieve, but something in the loop is not working for some reason.I have included the
var_dump( $page )
below for reference.object(WP_Post)#1531 (24) {
["ID"]=> int(157)
["post_author"]=> string(1) "8"
["post_date"]=> string(19) "2024-08-21 10:49:40"
["post_date_gmt"]=> string(19) "2024-08-21 16:49:40"
["post_content"]=> string(155) "This page will act as the primary landing page for various content that belongs in the contact section."
["post_title"]=> string(7) "Contact"
["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish"
["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed"
["post_password"]=> string(0) ""
["post_name"]=> string(7) "contact"
["to_ping"]=> string(0) ""
["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2024-10-15 12:36:20"
["post_modified_gmt"]=> string(19) "2024-10-15 18:36:20"
["post_content_filtered"]=> string(0) ""
["post_parent"]=> int(0)
["guid"]=> string(50) "https://beta.domain.com/child-site/?page_id=157"
["menu_order"]=> int(0)
["post_type"]=> string(4) "page"
["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw"
}Error
Warning: Undefined array key 0 in /var/www/domain.com/wp-includes/class-wp-query.php on line 3671
andWarning: Undefined array key 0 in /var/www/domain.com/wp-includes/class-wp-query.php on line 3766
Affected Functions from class-wp-query.php
public function next_post() {
++$this->current_post;
/** @var WP_Post */
$this->post = $this->posts[ $this->current_post ];
return $this->post;
}
public function rewind_posts() {
$this->current_post = -1;
if ( $this->post_count > 0 ) {
$this->post = $this->posts[0];
}
}Var dump
if ( have_posts() ) :
while ( have_posts() ) :
var_dump( the_post() );
get_template_part( 'template-parts/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile;
endif;The returned output of
var_dump( the_post() );
is NULL.Content Page template partial
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->There are two custom post types and taxonomies registered. They have been disabled for testing and do not have an effect on the errors.
I have commented out various functions in my theme’s functions.php file for testing purposes. None of the testing has yielded a successful result. None of the functions utilize the
the_content()
function.I have changed to the twentytwentyfour theme for testing and the pages and posts do load correctly. After re-enabling my custom theme, I disabled all plugins individually including Advanced Custom Fields Pro with no success.
I am at a loss on why this is occurring. I manage other multisites with none of these issues.
The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.