MyBB Community Forums

Full Version: Twitter Cards - MyBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I am trying to use twitter cards for forum threads, I saw this thread created for 1.6: https://community.mybb.com/thread-139524.html

As you can see in that thread, it looks like card needs "constant" thread title and thread image shown, I don't want that. 

I want twitter card to get thread title from the thread I am giving link of, and image from that thread aswell. Currently it works in Facebook like that, but for Twitter I need to add different code to headerinclude.

I would appreciate if anyone using Twitter cards for their forum can help with this, thank you.
Are you attempting to do the "Embed"? I'm not all that familiar with Twitter so I'm just making sure that is the 'card' you are talking about.
https://developer.twitter.com/en/docs/tw...s/overview

=====

SCRATCH THAT. I did a little more digging. I still do not fully understand what the card is for/what it does but here are docs: https://developer.twitter.com/en/docs/tw...ng-started

It also looks like you have to run URL through the validator tool, player card needs approval for whitelisting but all other cards do not so not sure if thats valid?

Quote:Get started in 4 simple steps
Ready to get started with Cards? In most cases, it takes less than 15 minutes to implement.
  • Choose a card type to implement.
  • Add the correct meta tags to the page.
  • Run the URL through the validator tool to test. If you are working with a Player Card, request approval for whitelisting. All other Cards do not need whitelisting.
  • After testing in the validator or approval of your Player Card, Tweet the URL and see the Card appear below your Tweet in the details view.
We hope you enjoy using Twitter Cards, and if you have any questions, drop us a line on the Twitter Cards Forum. Thanks, and happy coding!
Put this code in the showthread template between the <head> </head> tags

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="yourwebsite.com">
<meta name="twitter:creator" content="@YourTwitterHandle">
<meta name="twitter:title" content="{$thread['subject']} :: {$forum['name']} ">
<meta name="twitter:description" content="A thread by {$thread['username']}.">
<meta name="twitter:image" content="https://yourwebsite/images/picture.jpg">


Or, for custom images based on indiviusal forums, use this instead:

<meta name="twitter:image" content="https://yourwebsite/images/FILENAME/{$forum['fid']}.jpg">



If you want the images from the thread, I would have to see your site, to see what you mean. What thread images do you mean?

You can pull a user's avatar image with {$flp_avatar['avatar']} but you'd need to download flp avatar plugin
Yes I am trying to do embed, when I copy link I want twitter to show "twitter card" with non-constant title and image.

Michael2014, as you can see in that code, there's twitter:image and twitter:title, when you enter them - no matter what you share on Twitter, theres "same title and same image shown", what I want is, if I am sharing thread with title "God of War", then it should show "God of War", not constant "Gaming Forum" title. Same goes for image, I want twitter to take it from thread, same as Facebook is able to do right now for my forum.

This works with Wordpress, with Yoast SEO plugin. So it is technically possible, but I don't know to do it with MyBB.
I use the following code for my site and it works just fine for a non constant title. Did you try this as I have explained, in the showthread template?