The Parent Post of a recipe is the post, page or custom post type that contains the recipe card inside of it. On the WP Recipe Maker > Manage page you can check the “Parent Name” column to see what our plugin recognizes as being the parent post of a particular recipe.
The parent post is important, is it is used for several important features:
- The plugin uses ratings from comments given to the parent post of the recipe
- In the recipe metadata, links to the parent post are used for URL properties
- In a grid or index, clicking on a recipe will take you to its parent post
My Recipes have the Wrong Parent Post
When you save a post it looks for any recipes inside and associate itself as being the parent. So to change the parent post, try saving what should be its parent.
You can also try using the “Find Parents” button on the WP Recipe Maker > Tools page. Take note that you should probably disable “Automatically Lock First Parent Post” first, on the WP Recipe Maker > Settings > Post Type & Taxonomies page, otherwise it won’t change the currently associated parent post, since it’s locked in place.
My Recipes Don’t Have a Parent Post at all
When saving a post, WP Recipe Maker looks inside the post content for any recipes inside of it. If our plugin cannot find a recipe in the post content, it will not be able to assign the parent post correctly. This can happen if you’re using a non-compatible page builder or if you are not storing recipes in the post content at all (for example storing recipes in custom fields instead).
If you need a non-common setup like this, it is possible to manually assign the parent post as well, but this would require custom development. You could use the save_post hook to check when a post is being saved and then manually set the wprm_parent_post_id
meta for the recipe post type.
For example:
function wprm_check_for_parent_post_save( $post_id, $post ) {
// TODO, check if there is a recipe in the custom location you have saved it.
$recipe_id = false;
if ( $recipe_id ) {
// Set $post_id as the parent post for this $recipe_id.
update_post_meta( $recipe_id, 'wprm_parent_post_id', $post_id );
}
}
add_action( 'save_post', 'wprm_check_for_parent_post_save', 10, 2 );
Take note that you will probably also want to change the “Output Recipe Metadata” setting to “Next to recipe in HTML body element” on the WP Recipe Maker > Settings > Recipe Metadata page, as for outputting the metadata in the head, we also check for recipes in the post content.
So in general we highly recommend making sure the recipe shortcode is actually part of the post content, to ensure compatibility, but alternatives are possible with custom code.