ElasticPress Content Connect is a WordPress plugin that integrates Content Connect relationships with ElasticPress.
Filter by Content Connect post-to-post relationships.
- Advanced Filtering: Filter search results by Content Connect post-to-post relationships
- Flexible Query Types: Support for ID-based, slug-based, and title-based filtering
- Real-time Indexing: Automatically indexes relationships when they're created or modified
- Performance Optimized: Uses Elasticsearch nested queries for efficient relationship lookups
- PHP 7.4+
- WordPress 6.5
- ElasticPress
- Content Connect
- Elasticsearch per ElasticPress requirements
- Download the plugin ZIP file from the GitHub repository.
- Go to Plugins > Add New > Upload Plugin in your WordPress admin area.
- Upload the ZIP file and click Install Now.
- Activate the plugin.
To include this plugin as a dependency in your Composer-managed WordPress project:
- Add the plugin to your project using the following command:
composer require s3rgiosan/elasticpress-content-connect- Run
composer installto install the plugin. - Activate the plugin from your WordPress admin area or using WP-CLI.
- Navigate to "ElasticPress" > "Features".
- Enable "Post to Post Relationships" (see the Features section for more).
- Click "Save and sync now" or "Save and sync later" (sync is required for the feature to work).
Change the URL parameter names for filters:
add_filter( 'ep_content_connect_post_to_post_relationship_filter_name', function( $filter_name, $relationship_name, $post_type ) {
if ( $relationship_name === 'post-to-product' ) {
return 'related-product'; // Use ?related-product=123 instead of ?product=123
}
return $filter_name;
}, 10, 3 );Customize Elasticsearch field names:
add_filter( 'ep_content_connect_field_name', function( $field_name, $relationship_name, $post_type ) {
return $relationship_name . '_' . $post_type . '_relationships';
}, 10, 3 );Add extra data to indexed relationships:
add_filter( 'ep_content_connect_field_value', function( $field_value, $post ) {
$field_value['custom_field'] = get_post_meta( $post->ID, 'custom_field', true );
return $field_value;
}, 10, 2 );// Adjust maximum related posts per relationship
add_filter( 'ep_content_connect_related_posts_query_args', function( $args, $post_id, $relationship_name ) {
$args['posts_per_page'] = 150; // Default is 100
return $args;
}, 10, 3 );Enable filtering on custom pages:
add_filter( 'ep_content_connect_is_filterable_page', function( $is_filterable, $query ) {
if ( $query->is_page() && is_page( 'special-archive' ) ) {
return true;
}
return $is_filterable;
}, 10, 2 );The plugin automatically creates nested field mappings:
{
"post_to_product": {
"type": "nested",
"properties": {
"post_id": { "type": "integer" },
"post_title": {
"type": "text",
"fields": {
"raw": { "type": "keyword" }
}
},
"post_type": { "type": "keyword" },
"post_name": { "type": "keyword" }
}
}
}add_filter( 'ep_content_connect_post_to_post_relationships_field_mapping', function( $mapping ) {
$field_mapping['properties']['custom_field'] = [ 'type' => 'keyword' ];
return $mapping;
} );Relationship Data:
ep_content_connect_post_to_post_relationships- Modify available relationshipsep_content_connect_related_post_types- Modify related post typesep_content_connect_field_name- Customize field namesep_content_connect_field_value- Customize field values
Query Filtering:
ep_content_connect_is_filterable_page- Control which pages support filteringep_content_connect_post_to_post_relationship_filter_name- Customize URL parameter namesep_content_connect_post_to_post_relationship_filter_value- Sanitize filter valuesep_content_connect_post_to_post_relationship_filter_queries- Modify Elasticsearch queries
Performance:
ep_content_connect_related_posts_query_args- Optimize relationship queries
A complete listing of all notable changes to this project are documented in CHANGELOG.md.