Skip Navigation

[Resolved] How to make The Post Featured Image shortcode display the actual url?

This support ticket is created 4 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Shane 4 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1403265

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

#1403359

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