Describe the bug
The Good: I’ve gotten the cross-site searching working with ElasticSearch on a WP Multisite that’s running an FSE theme.
The Bug: sometimes, when $query->set( 'site__in', 'all' ); is on, the Header FSE template-part gets replaced with the post_content from another site’s post with the same ID. The Header template-part’s post_id is 510, but the content that is rendered on the front-end is from the 510 of another site on the network.
The fix was to add $query->set( 'cache_results', false );, as shown below.
Is this expected behavior?
function elasticsearch_network_search( $query ) {
… if ( is_admin() || ! $query->is_main_query() || ! $query->is_search() ) { return; }
$query->set( 'site__in', 'all' );
$query->set( 'cache_results', false );
}
add_action( 'pre_get_posts', 'elasticsearch_network_search');
Steps to Reproduce
On a multisite setup, have a search result include the post ID of a FSE template part used on the page
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress and ElasticPress information
No response
Code of Conduct
Describe the bug
The Good: I’ve gotten the cross-site searching working with ElasticSearch on a WP Multisite that’s running an FSE theme.
The Bug: sometimes, when
$query->set( 'site__in', 'all' );is on, the Header FSE template-part gets replaced with the post_content from another site’s post with the same ID. The Header template-part’s post_id is510, but the content that is rendered on the front-end is from the510of another site on the network.The fix was to add
$query->set( 'cache_results', false );, as shown below.Is this expected behavior?
Steps to Reproduce
On a multisite setup, have a search result include the post ID of a FSE template part used on the page
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress and ElasticPress information
No response
Code of Conduct