• Resolved mjleonett

    (@leonettmj)


    Hi, I have the next code in footer.php

    ?>
    <?php if(get_post_meta(get_the_id(), 'es_una_receta', true)) { ?>
    <script type="application/ld+json">
     {
     "@context": "http://schema.org/",
     "@type": "Recipe",
     "name": "<?php echo get_post_meta(get_the_id(), 'nombre_receta', true); ?>",
     "image": "<?php echo get_post_meta(get_the_id(), 'imagen_receta', true); ?>",
     "author": {
     "@type": "Person",
     "name": "<?php echo get_post_meta(get_the_id(), 'autor_receta', true); ?>"
     },
     "datePublished": "<?php the_date() ?>",
     "description": "<?php echo get_post_meta(get_the_id(), 'descripcion_receta', true); ?>",
     "prepTime": "<?php echo get_post_meta(get_the_id(), 'tiempo_prep_receta', true); ?>",
     "cooktime": "<?php echo get_post_meta(get_the_id(), 'tiempo_coccion_receta', true); ?>",
     "totalTime": "<?php echo get_post_meta(get_the_id(), 'tiempo_total_receta', true); ?>",
     "keywords": "<?php echo get_post_meta(get_the_id(), 'keywords_receta', true); ?>",
     "recipeYield": "<?php echo get_post_meta(get_the_id(), 'comensal_receta', true); ?>",
     "recipecategory": "<?php echo get_post_meta(get_the_id(), 'categoria_receta', true); ?>",
     "recipeIngredient": <?php echo json_encode(explode(",", get_post_meta(get_the_id(), 'ingredientes_recetas', true))); ?>,
     "recipeInstructions": "<?php echo get_post_meta(get_the_id(), 'instrucciones_receta', true); ?>",
     "aggregateRating": {
     "@type": "AggregateRating",
     "ratingValue": "<?php echo get_post_meta(get_the_id(), 'rating_average', true); ?>",
     "ratingCount": "<?php echo get_post_meta(get_the_id(), 'rating_count', true); ?>"
     },
    }
    </script>
    <?php } ?>

    My problem is that on custom fields I use this:

    rating_average: %customfield(_glsr_average)%
    rating_count: %customfield(_glsr_reviews)%

    but it does not work

    By another hand I would like to do this:

    "aggregateRating": {
     "@type": "AggregateRating",
     "ratingValue": glsr_get_ratings(['assigned_posts' => 'post_id',]);
     "ratingCount": glsr_get_ratings(['assigned_posts' => 'post_id',]);
     },
    }
    </script>
    <?php } ?>

    But I have no idea that I am doing.

    I would like your support. Thanks.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi there,

    You created very good plugin. I am also looking for solution to add manually recipes schema markup which will take rating from your plugin.

    If you have any solution, please let us know.

    Thanks,
    Petar

    Plugin Author Gemini Labs

    (@geminilabs)

    @leonettmj Try this:

     "ratingValue": "<?= get_post_meta(get_the_id(), '_glsr_average', true); ?>",
     "ratingCount": "<?= get_post_meta(get_the_id(), '_glsr_reviews', true); ?>"

    @perun5 Site Reviews integrates with other schema plugins. Let Site Reviews generate the AggregateRating schema, and use a proper schema plugin for the rest of your website.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Issue with Schema and custom fields’ is closed to new replies.