Showing specified articles sub-categories on home page
This support request was posted in Flatbase by kouchengfan
- kouchengfan November 21, 2017 at 6:57 am
Hi there,
I am trying to show some specified articles sub-categories on my home page by using below function and it does work.
// filter the knowledgebase parser function nice_knowledgebase_exclude_cat_home( $args ){ if ( is_home() || is_front_page() ) { $args['include'] = '83'; // replace 8 with the id of the category you want to exclude } return $args; } add_filter( 'nicethemes_knowledgebase_default_args', 'nice_knowledgebase_exclude_cat_home' );
I did try this code for parent categories but it doesnt work for sub-categories. Just wondering how can I only show the sub-categories that I want ?
Cheers
kouchengfan November 21, 2017 at 7:00 amAnd also, how do i change the order of the categories shown?
Juanfra Aldasoro November 21, 2017 at 1:16 pmHi,
Thank you for writing. I hope you are doing well.
The parameter you need to change is the one named “category”. For example, the following code will display the knowledgebase of categories that are a child of the category ID 8:
With regards to category order, we usually recommend the following plugin. You may want to give it a try and see if it suit your needs. https://wordpress.org/plugins/taxonomy-terms-order/
We’ve created an article explaining how to do it: https://nicethemes.com/article/ordering-categories/
Best,
Juan.kouchengfan January 12, 2018 at 7:04 amHi Juan,
above solution used to work on my previous version of Flatbase. However, it no longer work when I updated my flatbase to Version 2.0.1. Could you please point me out what went wrong?
Thank you for your help in advance.
Cheers
Juanfra Aldasoro January 12, 2018 at 1:20 pmHi,
Thank you for writing. I hope you are doing well.
Have you checked that you still have the code in the functions.php file?
Best,
Juan.kouchengfan January 12, 2018 at 10:54 pmyes, i did check. the code is still there. but just doesnt work.
Juanfra Aldasoro January 15, 2018 at 2:29 pmHi,
Thanks for the follow-up.
I’ve checked the code and it should be working for filtering first level categories. Would you please share your site URL in a private reply and let me know what categories are you trying to filter?
Best,
Juan.
You must be logged in to reply to this topic.