Hi Alvaro,
To accomplish this, you’ll need to associate the taxonomy with the reviews post type. Pippin wrote a great little tutorial on doing this here:
https://pippinsplugins.com/add-already-registered-taxonomy/
You’d want the second snippet which fires after all plugins are loaded.
That still won’t get you a convenient shortcode, though. To get there, you’d need to add an optional query arg for your topics term:
add_filter( 'grfwp_query_args', function( $args ) {
if ( !empty( $args['topic'] ) ) {
$this->args['tax_query'] = array(
array(
'taxonomy' => 'topic',
'field' => 'slug',
'terms' => $args['topic'],
)
);
}
return $args;
} );
Then register your own custom shortcode which accepts this new topic
parameter (this code just copies with slight modifications what’s in includes/template-functions.php
:
function alvaro_grfwp_reviews_shortcode( $atts ) {
// We must disable the automatic append to content filter while we're
// rendering the shortcode to prevent it from displaying twice
global $grfwp_controller;
remove_action( 'the_content', array( $grfwp_controller, 'append_to_content' ) );
$output = grfwp_print_reviews(
shortcode_atts(
array(
'review' => null,
'category' => null,
'random' => false,
'limit' => null,
'cycle' => false,
'excerpt' => false,
'topic' => false,
),
$atts
)
);
// Restore the_content filter
add_action( 'the_content', array( $grfwp_controller, 'append_to_content' ) );
return $output;
}
add_shortcode( 'alvaro-good-reviews', 'alvaro_grfwp_reviews_shortcode' );
That should do the trick, but please bear in mind that none of this code has been tested. You may need to work through typos or other issues.