Reuse one map configuration but change which posts load on a specific page (status, taxonomies, meta, include/exclude, order).
Steps
- Create your base map in admin.
- Embed it on the target page:
echo do_shortcode( '[cspm_main_map id="65"]' );
Or use the shortcode in the editor. For one-off curated lists, the shortcode attribute post_ids may be enough — see /**
* Override Progress Map query settings on a specific page.
*/
function cspm_custom_map_query_settings( $map_settings, $map_id, $fields_prefix ) {
if ( ! class_exists( 'CspmMainMap' ) ) {
return $map_settings;
}
// Change page ID (10) and map ID (65) to yours.
if ( ! is_page( 10 ) || (string) $map_id !== '65' ) {
return $map_settings;
}
// Status (must be serialized).
$map_settings[ $fields_prefix . '_items_status' ] = maybe_serialize( array( 'publish' ) );
// Taxonomies.
$taxonomies = array(
array(
'slug' => 'category',
'terms_ids' => array( 1, 2, 3 ),
'operator' => 'IN', // IN, NOT IN, AND, EXISTS, NOT EXISTS
),
);
foreach ( $taxonomies as $taxonomy ) {
$slug = $taxonomy['slug'];
$map_settings[ $fields_prefix . '_taxonomie_' . $slug ] = maybe_serialize( $taxonomy['terms_ids'] );
$map_settings[ $fields_prefix . '_' . $slug . '_operator_param' ] = $taxonomy['operator'];
}
if ( count( $taxonomies ) > 1 ) {
$map_settings[ $fields_prefix . '_taxonomy_relation_param' ] = 'OR'; // AND | OR
}
// Custom fields.
$custom_fields = array(
array(
'custom_field_name' => 'YOUR_CUSTOM_FIELD_KEY',
'custom_field_values' => 'YOUR_CUSTOM_FIELD_VALUE',
'custom_field_type' => 'CHAR',
'custom_field_compare_param' => '=',
),
);
if ( count( $custom_fields ) > 0 ) {
$map_settings[ $fields_prefix . '_custom_fields' ] = maybe_serialize( $custom_fields );
}
if ( count( $custom_fields ) > 1 ) {
$map_settings[ $fields_prefix . '_custom_field_relation_param' ] = 'OR';
}
// Include / exclude.
$post_in = array( 1, 2, 3 );
if ( count( $post_in ) > 0 ) {
$map_settings[ $fields_prefix . '_post_in' ] = maybe_serialize( $post_in );
}
$post_not_in = array();
if ( count( $post_not_in ) > 0 ) {
$map_settings[ $fields_prefix . '_post_not_in' ] = maybe_serialize( $post_not_in );
}
// Order.
$map_settings[ $fields_prefix . '_orderby_param' ] = 'ID';
$map_settings[ $fields_prefix . '_order_param' ] = 'DESC';
return $map_settings;
}
add_filter( 'cspm_map_settings', 'cspm_custom_map_query_settings', 10, 3 );
Tips
