• DH

    (@parisyearabroad)


    Hey everyone,

    I’m wondering if it’s possible to display subcategories on the category page instead of a list of all the posts in that category.

    For example, with a category of “Going out” and sub cats of “Bars” and “Clubs”, when someone clicks on “Going out” at the moment they see a list of posts such as Bar A, Club A, Bar B, Bar C etc.

    I would like to change that so that they instead see links to the “Bars” and “Clubs” subcats and don’t see the post excerpts until they are in the appropriate subcat. I hope this makes sense. I’ve looked around for a long time and can’t find anything that seems to do this.

    My coding knowledge is pretty limited. Is there a code that I can paste into one of the theme php files? I really appreciate all of your help! I’m using the Twenty Ten theme and the site is here: https://www.parisyearabroad.com

    I’m using the collapsing cats sidebar plugin which is great for the sidebar. It’s only the actual page that you land on when you click a category that I want to change.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter DH

    (@parisyearabroad)

    Sorry to be a pain. Does anyone have any ideas on this?

    Hey, I’m also having the same problem, or similar at least.

    Trying to get the page to display sub-catergories when you click on just the categories at the top. Have you had any luck in figuring this out?

    https://www.goodcat.co.uk

    if you want to do this for only the top categories, it could be done in category.php by checking if the category has a parent cat – if not, show a list of the sub-cats, if yes, show the posts.

    example:

    $cat = get_query_var('cat');
    if( get_category($cat)->category_parent ) :
    /*the loop to show the category posts; if needed with a custom query to restrict it to the direct category*/
    else :
    /*list of sub categories; possibly with wp_list_categories() nad the 'child_of' or 'parent' parameter*/
    endif;

    for details look-up the functions in the codex

    I’m trying to do this for a homepage slideshow. Can it be done? The function code for the slideshow is this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Thank you in advance,

    Razvan Costica
    [sig moderated as per the Forum Rules]

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display subcategories on category page instead of posts’ is closed to new replies.