- This topic has 18 replies, 3 voices, and was last updated 3 years, 6 months ago by David.
-
AuthorPosts
-
October 27, 2020 at 11:51 am #1506874Sagar
Hi,
I want to show featured image caption on all my blog posts. Captions are to be entered manually to give the attribution.Like this news website has given
https://www.hindustantimes.com/it-s-viral/dad-s-complete-guide-to-baby-video-is-absolutely-hilarious-watch/story-opDXsEccg885ZFQXLnWooL.htmlThe caption is: “The image shows a shot from the video. (Instagram/@howtodadnz)”
Remember that, it will be different for all the blog posts.
Thank you
October 27, 2020 at 12:09 pm #1506893LeoStaffCustomer SupportHi there,
This snippet is the best for this:
https://gist.github.com/diggeddy/5f7c3a4584a8beb51febc9c4f33d6c5cIt needs to be added using one of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/Then you can just use the default Caption field from WordPress media library:
https://www.screencast.com/t/asrNiTgXp8WBLet me know if this helps 🙂
October 27, 2020 at 12:15 pm #1506901SagarThank you, Leo.
But when I’m checking my AMP pages, the caption is showing two times. What’s wrong now?
Check here: https://urbanhomecart.com/best-dishwasher-india/amp/the caption is ‘Dishwasher’
October 27, 2020 at 5:38 pm #1507102LeoStaffCustomer SupportI’m really sure how AMP handles a WordPress option mod like this unfortunately.
Would this CSS help?
.wp-caption .wp-caption-text:not(.thumb-caption-text) { display: none; }
Adding CSS: https://docs.generatepress.com/article/adding-css/
October 27, 2020 at 10:09 pm #1507214SagarHi Leo,
Why don’t you enable this as a default option for all the users? If anyone wants to use it they will use otherwise no.
It’s just a small thing which much be enabled by default.October 27, 2020 at 11:01 pm #1507238SagarOctober 28, 2020 at 3:53 am #1507502DavidStaffCustomer SupportWhich Amp plugin are you using ?
October 28, 2020 at 4:28 am #1507535SagarI’m using AMP by Automattic
https://wordpress.org/plugins/amp/October 28, 2020 at 5:32 am #1507619DavidStaffCustomer SupportIn the code Leo provided a link to here:
Try changing this:
} else {
to
} elseif( !is_amp_endpoint() ) {
October 28, 2020 at 11:36 am #1508355SagarWhy don’t you enable this as a default option for all the users? If anyone wants to use it they will use otherwise no.
It’s just a small thing that must be enabled by default.
Playing with codes is a scary thing for me for my website.October 28, 2020 at 11:39 am #1508360Sagar} else {
to
} elseif( !is_amp_endpoint() ) {
I did this. Now the featured image is not showing in the amp pages.
October 28, 2020 at 11:41 am #1508364LeoStaffCustomer SupportI’ll check with David to see if the code can be modified some more.
Thanks for the suggestion.
I’ll mention it to our team 🙂
October 28, 2020 at 11:47 am #1508373DavidStaffCustomer SupportSorry about that – revert that change and instead try updating this line:
if( $html == '' ) {
to
if( $html == '' || is_amp_endpoint() ) {
October 28, 2020 at 11:51 am #1508378SagarAgain, none of the featured images showing on any AMP page after this code.
October 28, 2020 at 12:01 pm #1508393SagarSorry, I cleared the cache. Now it is working well. But please take my feedback to enable this featured image caption by default in the GP theme.
As I’m really too far away from coding. -
AuthorPosts
- You must be logged in to reply to this topic.