I am trying to:
Display the image from a media attachment page.
Link to a page where the issue can be seen: Issue is on private pages.
I expected to see:
Prior to update to Views 3.0.1 and WP 5.3, [wpv-post-body view_template="None" item="123"] would show the attachment page's image and Description (if any).
Instead, I got:
Only the description appears now.
I understand from the changelog that this may have been an intended change at Views 2.9.4, but can't figure out how to extract the image from the attachment ID now. Could you advise please?
Hello,
I assume we are talking about a media attachment, ID is 123.
I have tried it in my localhost, with below steps:
1) WordPress 3.0 (https://wordpress.org/download/releases/) + Toolset Views plugin 3.0.1,
Test the shortcode you mentioned above:
[wpv-post-body view_template="None" item="123"]
I can see only the image description,
2) WordPress 3.0 (https://wordpress.org/download/releases/) + Toolset Views plugin 2.9.4
Same as above, I can see only the image description,
In the latest version of Views plugin, you can try these:
1) add below PHP codes into your theme file functions.php:
add_shortcode('attach-url', function($atts, $content){
return wp_get_attachment_url($atts['id']);
});
2) Use below shortcode to get attachment info, like this:
URL:
[attach-url id=123]
Alt:
[wpv-post-field name="_wp_attachment_image_alt" item=123]
Title:
[wpv-post-title item=123]
Thanks Luo, that's helped me in the right direction.