I am pulling Custom Post Type (JetEngine) data with Query Loop to the page I created with Bricks Builder. When we search from this data, the page I created on the search results page does not appear in the results.
In Bricks Builder Miscellaneous settings, “Query Bricks data in search results” is marked as on.
Example: I am pulling people to your “Who we are” page with Query Loop.
Yes, this option is on and it is working fine for static content inside the builder. Everything inside the query loop that is dynamic is not being indexed.
I built a page with bricks which has a query loop of some terms and custom post type tied to them. When I do a search of regular text, this does work and is indexed and appear in the search results but when I try to search for the post title of the custom post type or term, the page doesn’t appear in the results.
If I search the literal dynamic tag without the brackets “term_name” or “post_title” they do appear so I guess this is not saved but the template string? Is this what Query Bricks data in search results is for? The rendered version of the page is not indexed? I can only make the content indexable if I add the bricks content as a template, or component but doesn’t sound like a good idea.
Is this intended? I guess on save one can build the content and save it in a custom field and use relevanssi to index the content?
Edit: For now using hooks from Relevanssi and building the index
add_filter( 'relevanssi_content_to_index', function( $content, $post ) {
// Ignore content that is not a page
if ( ! in_array( $post->post_type, ['page'], true ) ) {
return $content;
}
// Get the bricks data
$bricks_data = get_post_meta( $post->ID, '_bricks_page_content_2', true );
if ( empty( $bricks_data ) ) {
return $content;
}
// Render the content from bricks data and save it in a post meta
// to highglight in the search results
ob_start();
Bricks\Frontend::render_content( $bricks_data );
$content = ob_get_clean() . ' ' . $content;
update_post_meta( $post->ID, '_bricks_index_content', $content );
return $content;
}, 10, 2 );
add_filter( 'relevanssi_pre_excerpt_content', function( $content, $post, $query ) {
$bricks_content = get_post_meta( $post->ID, '_bricks_index_content', true );
return ! empty( $bricks_content ) ? $bricks_content : $content;
}, 10, 3 );