Skip to content

Instantly share code, notes, and snippets.

@schemapress
Last active February 17, 2021 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schemapress/68582975967f2a033e98fdcc6401fa6b to your computer and use it in GitHub Desktop.
Save schemapress/68582975967f2a033e98fdcc6401fa6b to your computer and use it in GitHub Desktop.
Display a list of Recipe Ingredient with the Schema plugin for WordPress https://schema.press/docs-premium/add-schema-org-recipe/
<?php //* do not include php tag
/**
* Display Recipe Ingredient
*
* @since 1.0.0
* @return null
*/
function schema_display_recipeIngredient_78239482379847() {
$output = '';
$count = get_post_meta( get_the_ID(), 'schema_properties_Recipe_recipeIngredient', true );
if ( isset( $count ) && $count >= 0 ) {
$output .= '<ul>';
for( $i=0; $i < $count; $i++ ) {
$ingredients = get_post_meta( get_the_ID(), 'schema_properties_Recipe_recipeIngredient_' . $i . '_recipeIngredient_item', true );
if ( isset($ingredients) && $ingredients != '' ) {
$output .= '<li>' . $ingredients . '</li>';
}
}
$output .= '</ul>';
}
if ( $output != '' ) {
echo $output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment