【问题标题】:Wordpress - Hide specific postsWordpress - 隐藏特定帖子
【发布时间】:2011-10-22 20:21:17
【问题描述】:

我正在编写一个 wordpress 插件,我想隐藏标题中包含特定字符串的帖子/页面。

例如,我想隐藏标题包含的所有帖子/页面:[something123]

显示此帖子/页面“Lorem Ipsum”
隐藏此帖子/页面“Lorem Ipsum [something123]”
隐藏此帖子/页面“Hello World [something123]”
显示此帖子/页面“Hello World”

【问题讨论】:

    标签: wordpress plugins posts


    【解决方案1】:

    在你的主题目录中找到loop.php

    里面应该有这样一行

    <?php while ( have_posts() ) : the_post(); ?>
    

    伪代码:

    if (get_the_title() contains "") { endwhile; }
    

    http://codex.wordpress.org/Function_Reference/get_the_title

    你也可以使用过滤器:

    http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where

    虽然我不想为你写一篇=)。也许其他人会。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-07
      • 2021-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多