Hi,
I have a CPT called "books".
I have implemented the Google recommended JSON-LD code for books in these posts.
One of the requirements is to show the book cover (featured image) url, like this:
<em><u>hidden link</u></em>
However, due to caching from Jetpack,, when I use this shortcode:
[wpv-post-featured-image size="full" output="url"]
I get this cached version:
<em><u>hidden link</u></em>
Which is uselss for the JSON-LD code, becasue I don't own the wp.com site, so the Google webmaster tools refuse to crawl this image.
So is there a way to alter the shortcode to just display the actual image url, not the cached version?
thanks
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Atef,
Thank you for getting in touch.
What you can do is to try the following custom shortcode below.
// Add Shortcode
function wp_featured_url( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'id' => '',
),
$atts
);
$url = get_the_post_thumbnail_url($atts['id']);
return $url;
}
add_shortcode( 'featured_url', 'wp_featured_url' );
Add this to your custom shortcodes in Toolset -> Settings -> Custom Code then activate it.
Finally you can use the shortcode like this on your posts.
[featured_url id='[wpv-post-id]']
Please let me know if this helps.
Thanks,
Shane