问题描述
我在WordPress网站上使用短代码来帮助显示BibTeX文件中文章的参考信息。例如,使用
public mannar() { // constructor
initComponents();
fillCombo();
}
private void fillCombo() {
try {
Class.forName("com.MysqL.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:MysqL://localhost:3306/odemetrics","root","");
String sql0 = "SELECT * FROM station";
PreparedStatement pst0 = con.prepareStatement(sql0);
ResultSet rs = pst0.executeQuery();
while (rs.next()) {
String stations = rs.getString("stname");
JComboBox combo = new JComboBox();
combo.addItem(stations);
table_man.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(combo));
}
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
System.out.println(e);
}
}
形式的简码以这种方式生成my post顶部的文章信息,其中id是BibTeX文件中的参考id。我正在使用[bibtex key="id"]
插件。
但是,当我使用上面的URL鸣叫这篇文章时,我得到的是简码文本本身,而不是简码输出。参见:
https://twitter.com/JDHamkins/status/1306124193357074433
为什么Twitter在这里使用简码文本,以及如何使用它代替输出文本?
解决方法
这是因为Twitter在标题中使用了<meta property="og:...">
标签,而不是页面文本:
<!-- 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=”HamkinsSolberg:Categorical-large-cardinals”]" />
<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提供了一些有关https://jetpack.com/tag/open-graph/的帮助-如何手动更改其开放式图形插件的功能,但这可能需要一些工作
,如果您查看源HTML,则其中包含以下行
<!-- Jetpack Open Graph Tags -->
...
<meta property="og:description" content="[bibtex key=”HamkinsSolberg:Categorical-large-cardinals”]" />
...
<!-- End Jetpack Open Graph Tags -->
因此,看来Jetpack WP插件无法处理简码。
我建议在[bibtex]行之前在文章顶部添加一个介绍性句子。像摘要的一句话摘要一样?
更新:显然,可以使用Yoast SEO插件来解决该问题,请参见https://randomneuronsfiring.com/jetpack-publicize-setting-the-image-and-text-shown-on-twitter-and-facebook/