将 discourse 分类链接添加到 wordpress

你好,

很遗憾,据我所见,没有直接提供该选项。但你可以通过以下步骤实现:

  1. 安装 Discourse 短代码插件,并在你的文本侧边栏小部件中使用短代码 [discourse_topics]

  2. 导航到 wp-discourse-shortcodes-master / lib / discourse-topic-formatter.php,查找以下代码行:
    $category = $this->find_discourse_category( $topic );

  3. 在该行之后,粘贴以下内容:
    $category_url = $this->discourse_url . "/c/{$category['slug']}/{$category['id']}";

  4. 搜索以下内容(你会找到两行,分别对应顶部和底部位置):
    $output .= '<span class="wpds-shortcode-category">' . $this->discourse_category_badge( $category ) . '</span>';

  5. 将它们替换为:
    $output .= '<span class="wpds-shortcode-category"><a class="wps-cat-link" target="_blank" href="' . esc_url( $category_url ) . '">' . $this->discourse_category_badge( $category ) . '</a></span>';

  6. 进入你的 WordPress 后台,勾选此选项并点击“保存设置”。

请注意,当你更新 wp-discourse-shortcodes 插件时,这些修改会被覆盖,因此在更新前建议进行备份。祝你好运!