Plugin hooks and filters

Plugin hooks can be used to alter the plugin functionality or output without directly editing the plugin files (you should not do that, as those changes will get overwritten on update). This is for advanced users who are comfortable with PHP only.

Block Shortcode Hooks

Block shortcodes are used in our Modern Templates to output different parts of the recipe. All of these have a plugin hook to filter the attributes and one to filter the output.

Filter Block Shortcodes Attributes

Filter what's used as the shortcode attributes using the shortcode_atts_%wprm_shortcode_with_underscores% hook. For example:

function recipe_name_attributes( $attributes ) {
	return $attributes;
add_filter( 'shortcode_atts_wprm_recipe_name', 'recipe_name_attributes' );

Filter Block Shortcodes Output

Filter what a block shortcode outputs using the  %wprm_shortcode_with_underscores%_shortcode hook. For example:

function recipe_name_output( $output, $attributes, $recipe ) {
	return $output;
add_filter( 'wprm_recipe_name_shortcode', 'recipe_name_output', 10, 3 );

Take note: for general blocks the $recipe variable will not be set.

Other Plugin Hooks

This table lists all other available plugin hooks:

Hook Attributes Description
$post, $recipe_id
Adjust what's passed to wp_insert_post() for the parent post when using the "Approve and add recipe submission to post" option
wprm_nutrition_ingredient_taxonomy $args Arguments used to create the wprm_nutrition_ingredient taxonomy
$output, $type, $selector
Hook into the custom CSS that gets output to the <head>
$template Template for the rating inside a comment
$template Template for the comment rating form
$metadata, $recipe JSON-LD metadata for a recipe
$args Arguments for the WPRM_POST_TYPE register_post_type()
$units Units recognized when parsing ingredients
$taxonomies Taxonomies to register with their labels
$output, $recipe, $type, $slug
Output for a recipe
wprm_recipe_shortcode_output $output, $recipe, $type, $slug The entire shortcode output
$icon What to use for the empty star rating icon
wprm_comment_rating_star_full_icon $icon What to use for the full star rating icon
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.