We write a product that creates dynamic content for pages that do not exist in WP. We create these posts by filtering the_posts
, and only kicking in when the url does not exist in the site. When this is true, we check to see if the url (real estate listings) exists.
We’ve done this for years, and works on most themes. But something is happening with the ‘x’ theme. I’ve spent 3 days investigating theme settings that might help, and adding debug to understand the issue.
We create a post thusly:
$post = new stdClass();
$post->post_author = get_current_user_id();
$post->post_name = "1924 County Rd 138";
$post->post_type = 'page';
...
$post = new WP_Post( $post );
wp_cache_add( $post->ID, $post, 'posts' );
unset($wp_query->query["error"]);
$wp_query->query_vars["error"] = "";
$wp_query->is_404 = false;
$GLOBALS['wp_query'] = $wp_query;
$wp->register_globals();
But this post, on the ‘x’ theme, is being discarded by something, somewhere.
This is a page that works (not using ‘x’ theme):
https://islandviewrealty.com/singlefamily/mn/international-falls/1924-county-rd-138/
This is a page that discards this generated content (using ‘x’ theme):
https://staging.islandview.sites.roveridx.com/singlefamily/mn/international-falls/1924-county-rd-138/
I’ve added debug, I can see the_content is generated correctly and before the page is rendered. I added debug to template-blank-1.php, and can see that it’s call to the_content() is returning different content, not the content we generated.
I’m not sure where to look next, and am looking for guidance.
Thank you