-
AuthorPosts
-
December 30th, 2018 at 17:13 #72183December 31st, 2018 at 18:15 #72258ZedCryout Creations mastermind
The theme is not responsible for how social embeds work. For fine control over how this behaves use a SEO or social sharing plugin.
If you like our creations, help us share by rating them on WordPress.org.
Please check the available documentation and search the forums before starting a topic.December 31st, 2018 at 22:31 #72265I have another website using another theme and I don’t have this issue (and I haven’t installed any social SEO or sharing plugin). This is not happening when tweeting youtube’s url, the thumb is automatically generated. I tried the twitter validator https://cards-dev.twitter.com/validator and I got the following error:
INFO: Page fetched successfully INFO: 5 metatags were found ERROR: No card found (Card error)
It seems that the page (website) needs to include metadata to show the image: https://twittercommunity.com/t/error-no-card-found-card-error/107179
Any help is appreciated.
Thanks,
Claudia- This reply was modified 5 years ago by claubs.
January 1st, 2019 at 19:39 #72277ZedCryout Creations mastermindThat depends on what theme you’re comparing with. WordPress.org repository themes are not allowed to include plugin-like functionality (social embed optimizations are such functionality).
If you like our creations, help us share by rating them on WordPress.org.
Please check the available documentation and search the forums before starting a topic.January 3rd, 2019 at 03:16 #72317I was able to fix it just adding the following code to the child theme. Just sharing the code just in case helps someone else:
add_action('wp_head', 'add_twitter_cards'); function add_twitter_cards() { if(is_single() || is_page()) { $tc_url = get_permalink(); $tc_title = get_the_title(); $tc_description = get_the_excerpt(); $tc_images = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), full ); $tc_image_thumb = $tc_images[0]; if(!$tc_image_thumb) { $tc_image_thumb = 'my-url-for-page-thumbs'; } $tc_author = str_replace('@', '', get_the_author_meta('twitter')); ?> <meta name="twitter:card" value="summary" /> <meta name="twitter:site" value="@my-twitter-account" /> <meta name="twitter:title" value="<?php echo $tc_title; ?>" /> <meta name="twitter:description" value="<?php echo $tc_description; ?>" /> <meta name="twitter:url" value="<?php echo $tc_url; ?>" /> <meta name="twitter:image" value="<?php echo $tc_image_thumb; ?>" /> <?php if($tc_author) { ?> <meta name="twitter:creator" value="@<?php echo $tc_author; ?>" /> <? } } } ?>
All the best,
Claudia -
AuthorPosts
The topic ‘Twitter card not working for blog posts’ is closed to new replies.