Last active
February 17, 2021 15:55
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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