Shortcode for /structured_data placement
-
I have a very large older recipe site that, for my own reasons, I don’t want to use json, and instead want to use microdata.
I have been able to use the editor in the plugin to make the output microdata and then i removed the script and json tags from plugin files so it was showing up as meta data, but I can’t seem to control the location of where the plugin places the structured data.
I see it’s putting it in the head, and I can move to the footer, but the ratings don’t show up as part of my recipe structured data in wordpress, it shows up as a different section.
I want to be able to use shortcode to place the structured data output in a specific place on my theme file, that is in my recipe card to already be part of the structured data I have in my recipe microdata.
Is this possible altering this piece of code from your plugin? Seems like there’s a simple solution I’m not thinking of. Maybe to make this into a shortcode call? but I just don’t know how to do it.
(I’ve already deleted the script part to make it html.)add_action(‘wp_head’, __NAMESPACE__.’\structured_data’);
function structured_data()
{
if (! get_option(prefix(‘enable’))) {
return;
}if (get_option(prefix(‘grs’))
&& (is_singular() || is_page())
) {
$id = get_post_field(‘ID’);
$title = htmlentities(get_post_field(‘post_title’));
$best = max((int) get_option(prefix(‘stars’)), 1);
$count = count_filter(null, $id, null);
$score = score_filter(null, $best, $id, null);if ($score) {
echo ”;
$sd = get_option(prefix(‘sd’));
$sd = str_replace(‘[title]’, $title, $sd);
$sd = str_replace(‘[best]’, $best, $sd);
$sd = str_replace(‘[count]’, $count, $sd);
$sd = str_replace(‘[score]’, $score, $sd);
echo $sd;
echo ”;
}
}
}The page I need help with: [log in to see the link]
- The topic ‘Shortcode for /structured_data placement’ is closed to new replies.