Showing specified articles sub-categories on home page

This support request was posted in Flatbase by kouchengfan

Request ID #35372 In Progress
  • 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

    And also, how do i change the order of the categories shown?

    Hi,

    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.

    Hi 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

    Hi,

    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.

    yes, i did check. the code is still there. but just doesnt work.

    Juanfra Aldasoro

    Hi,

    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.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Login to your Account

Welcome back! Please log in to your account by filling the fields below:

Forgot?

Not a member? Create a free account.

Create a Free Account

You're 27 seconds away from some awesome WordPress free stuff, benefits and more. Create a free account and have access to our free products, benefits and more!

Already have an account? Log in
Secure Server