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...