Search code examples
twitterwordpress-shortcode

When Tweeting my Wordpress post, how to get shortcode output to appear instead of shortcode text?


I use shortcodes on my WordPress site to help display reference information from my articles from a BibTeX file. For example, the article information at the top of my post is generated this way, using a shortcode of the form [bibtex key="id"], where id is the reference id in the BibTeX file. I am using the papercite plugin.

When I tweet this post, however, using the URL above, what I get instead is the shortcode text itself, instead of the shortcode output. See:

https://twitter.com/JDHamkins/status/1306124193357074433

Why is Twitter using the shortcode text here, and how to I get it to use the output text instead?


Solution

  • If you look at the source HTML, it has the lines

    <!-- Jetpack Open Graph Tags -->
    ...
    <meta property="og:description" content="[bibtex key=&#8221;HamkinsSolberg:Categorical-large-cardinals&#8221;]" />
    ...
    <!-- End Jetpack Open Graph Tags -->
    

    So it looks like the Jetpack WP plugin doesn't process the shortcodes.

    I'd suggest to add an introductory sentence at the top of the post, before the [bibtex] line. Like maybe a 1-sentence summary of the abstract?

    Update: Apparently the Yoast SEO Plugin can be used to solve the issue, see https://randomneuronsfiring.com/jetpack-publicize-setting-the-image-and-text-shown-on-twitter-and-facebook/