您好,
我在我的 WordPress 安装中使用了自定义评论模板。因此,我不想启用 WP Discourse 中提供的“评论”功能。
我现在想实现的是对现有模板的扩展:
- 如何查询帖子是否已在 Discourse 中发布?
- 如果检查返回“true”(已发布),我只想在 Discourse 论坛中包含指向该帖子的链接
如何实现这一点?
您好,
我在我的 WordPress 安装中使用了自定义评论模板。因此,我不想启用 WP Discourse 中提供的“评论”功能。
我现在想实现的是对现有模板的扩展:
如何实现这一点?
如果使用 WP Discourse 插件将帖子发布到 Discourse,则该帖子的永久链接将保存在 wp 帖子元字段 discourse_permalink 中。因此,您只需在主题中想要显示链接的位置显示它即可。类似这样:
<li><a href="<?php get_post_meta(get_the_ID(), 'discourse_permalink', true); ?>">在我们的论坛上讨论</a></li>
谢谢 @angus。
我搞定了! ![]()
if ( get_post_meta( get_the_ID(), 'discourse_permalink', true ) ) {
$discourse_permalink = get_post_meta( $post->ID, 'discourse_permalink', true );
echo '<a href="' . esc_url( $discourse_permalink ) . '" title="Forum">在我们的论坛上评论</a>';
}