【问题标题】:Is it possible to use a custom sidebar per post in wordpress?是否可以在 wordpress 中为每个帖子使用自定义侧边栏?
【发布时间】:2016-11-06 04:52:52
【问题描述】:

是否可以在 Wordpress 中为每个帖子使用自定义侧边栏而不将其编码到模板中?

我尝试使用 Flexible Posts Widget 插件,但无法正常工作。

【问题讨论】:

  • 不,您必须在 single.php 中使用 if else 进行编码,或者您可以制作一个自定义侧边栏,接受帖子 ID 作为参数并返回与该帖子 ID 相关的侧边栏@SaifulIslamsaifultech

标签: wordpress sidebar


【解决方案1】:

如果该侧边栏不存在,则需要 register_sidebar(), 然后到特定模板中的 get_sidebar( string $name = null )。 但是,如果相同的侧边栏出现在其他页面上,并且您只需要限制特定小部件的每个帖子的可见性, 尝试使用与小部件可见性相关的插件,即 https://wordpress.org/plugins/widget-visibility-without-jetpack/ 或者 https://wordpress.org/plugins/widget-visibility/ 找出更适合您需求的方法。 您将获得每个小部件的“可见性”按钮,然后您可以设置要显示的帖子。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    • 1970-01-01
    相关资源
    最近更新 更多