內容簡介
這個外掛啟用後,只會在迴圈中顯示當前分類的文章(不會顯示子分類中的文章)。
這就是它的全部功能,沒有任何選項。如果您需要選項,請告訴我,我會加入進去。
從 0.4 開始,我在主查詢(main query)建立後移除過濾器,以免與小工具(widget)產生衝突。
如果您有自定義查詢或是在分類存檔模板中呼叫 wp_query,您需要在查詢之前和之後添加和移除過濾器。下面是一個使用 wp_query 的示例。再次重申,只有在模板文件中修改查詢時才需要這樣做。
add_filter( 'posts_where', 'ft_nscp_mod_where' );
query_posts( array( 'your-custom' => 'args' ) );
remove_filter( 'posts_where', 'ft_nscp_mod_where' );
重要的是要刪除您添加的內容。
外掛標籤
開發者團隊
② 後台搜尋「No Sub-Category Posts in Loops」→ 直接安裝(推薦)
原文外掛簡介
Once activated, only posts from the current category are displayed in your loop (no posts from sub cats).
That’s all it does. No options. If you find you need options, let me know and I’ll build them into it.
As of 0.4 I remove the filter after the main query is built so that it doesn’t interfere with widgets.
If you have a custom query or call wp_query on a category archive template, you’ll need to add and remove the filters before and after your query. Below is an example of how to do this if you use wp_query. Again, this is not necessary unless you have modified queries in a template file.
add_filter( 'posts_where', 'ft_nscp_mod_where' );
query_posts( array( 'your-custom' => 'args' ) );
remove_filter( 'posts_where', 'ft_nscp_mod_where' );
Its important that you remove what you add.
