GG资源网

修改显示哪些WordPress类别

问题描述:

I\'m building a bespoke WordPress theme for a periodical. I have a category set up that basically marks an article as \"featured,\" making them appear on the homepage. I\'d like for this category to not appear when browsing the site, however, as it\'s meant for the magazine\'s staff to be able to control what\'s on the homepage, rather than be used as a tool for user\'s to search with.

Since the_category(); will return all categories, I need help building a php loop that will display categories while skipping this one. A post will only ever have one category, unless this second one is applied. I also think building a function that could be referenced several times across the site would be the most efficient way of handling this.

If there\'s an even simpler method to reach the same outcome, feel free to point that out as well. I\'d just like to keep my plugin dependencies minimal. Thanks for your assistance!

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~
功能建议

我正在为期刊制作一个定制的WordPress主题。 我有一个类别设置基本上将文章标记为“特色”,使它们出现在主页上。 我希望这个类别在浏览网站时不会出现,因为它意味着杂志的工作人员能够控制主页上的内容,而不是用作用户搜索的工具。</ p >

由于the_category(); 将返回所有类别,我需要帮助构建一个PHP循环,将显示类别,同时跳过这一个。 除非第二个类别被应用,否则帖子将只有一个类别。 我还认为构建一个可以在整个站点上多次引用的函数将是处理此问题的最有效方法。</ p>

如果有更简单的方法可以达到相同的结果,请随意 也指出了这一点。 我只想保持我的插件依赖性最小化。 谢谢你的协助! </ p>
</ div>

网友观点:

After doing more research into my options for developing with WordPress, I\'ve found that using a custom post type will work far better than filing these posts under a category. Apologies for the confusing post.

###

You\'ll first have to find the id of the \\\"featured\\\" category.

Then find the php pages where the categories are displayed (I know they are in single.php for instance).

Once you\'ve done that, just add a if/else statement to display categories only if the category isn\'t \\\"featured\\\":

由于网站搬家,部分链接失效,如无法下载,请联系站长!谢谢支持!
1. 带 [亲测] 说明源码已经被站长亲测过!
2. 下载后的源码请在24小时内删除,仅供学习用途!
3. 分享目的仅供大家学习和交流,请不要用于商业用途!
4. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
5. 本站所有资源来源于站长上传和网络,如有侵权请邮件联系站长!
6. 没带 [亲测] 代表站长时间紧促,站长会保持每天更新 [亲测] 源码 !
7. 盗版ripro用户购买ripro美化无担保,若设置不成功/不生效我们不支持退款!
8. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
9. 如果你也有好源码或者教程,可以到审核区发布,分享有金币奖励和额外收入!
10.如果您购买了某个产品,而我们还没来得及更新,请联系站长或留言催更,谢谢理解 !
GG资源网 » 修改显示哪些WordPress类别

发表回复

CAPTCHAis initialing...