1

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?

1

2 Answers 2

1

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/

Sign up to request clarification or add additional context in comments.

3 Comments

Good idea. I think that will be an easy workaround.
Unfortunately, this method doesn't work after all. In my tweet twitter.com/JDHamkins/status/1308305279222652930 about my latest paper, I had put text before the shortcode in the blog post, but still Twitter grabbed the shortcode text instead of that introductory sentence.
@Joel, I edited the answer... you may try to use the Yoast SEO Plugin specifically to fix this.
1

It will be because Twitter uses the <meta property="og:..."> tags in the header rather than using the page text:

<!-- Jetpack Open Graph Tags -->
<meta property="og:type" content="article" />
<meta property="og:title" content="Categorical large cardinals and the tension between categoricity and set-theoretic reflection" />
<meta property="og:url" content="http://jdh.hamkins.org/categorical-large-cardinals/" />
<meta property="og:description" content="[bibtex key=&#8221;HamkinsSolberg:Categorical-large-cardinals&#8221;]" />
<meta property="article:published_time" content="2020-09-16T06:50:00+00:00" />
<meta property="article:modified_time" content="2020-09-16T06:50:04+00:00" />
<meta property="og:site_name" content="Joel David Hamkins" />
<meta property="og:image" content="http://jdh.hamkins.org/wp-content/uploads/Categorical-cardinals-Venn-diagram.jpg" />
<meta property="og:image:width" content="504" />
<meta property="og:image:height" content="306" />
<meta property="og:locale" content="en_US" />
<meta name="twitter:site" content="@JDHamkins" />
<meta name="twitter:text:title" content="Categorical large cardinals and the tension between categoricity and set-theoretic reflection" />
<meta name="twitter:card" content="summary" />

JetPack offer some help — https://jetpack.com/tag/open-graph/ — on how to manually alter what their open graph plugin does, but it may take some work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.