Forums

List all (sitewide, not post-related) categories on post's page (single.php) (9 posts)

  1. Basty
    Member
    Posted 7 months ago #

    Greetings!

    Is there any way to list all categories (not only those for the current post) on a post's page (single.php)?

    I've been searching for 5 hours now and found no solution, every query I've tried relates to the current post / loop.

    Thank you!

  2. keesiemeijer
    moderator
    Posted 7 months ago #

  3. Basty
    Member
    Posted 7 months ago #

    Tried both solutions, they only retrieve categories for the current post for some reason.

    I need to list all categories, not just those for the current post, both empty or not.

  4. keesiemeijer
    moderator
    Posted 7 months ago #

    If <?php wp_list_categories(); ?> only gives categories of the current post.

    try:
    - deactivating all plugins to see if this resolves the problem? If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the default theme to rule out any theme-specific problems?

  5. Basty
    Member
    Posted 7 months ago #

    Thank you for your prompt replies, keesiemeijer.

    I've modified single.php on the default theme before activating it and wp_list_categories(); works as it's supposed to.

    Now I'm digging through the other theme's code to find the culprit.

    Hopefully it's nothing too silly that's preventing wp_list_categories(); from working properly or I'll look like a complete fool.

  6. keesiemeijer
    moderator
    Posted 7 months ago #

    What theme are you using?

  7. Basty
    Member
    Posted 7 months ago #

    A custom theme, started by someone else and taken over by yours truly.

  8. keesiemeijer
    moderator
    Posted 7 months ago #

    Is there something simular to: add_filter('wp_list_categories', 'function_name'); in your functions.php

  9. Basty
    Member
    Posted 7 months ago #

    Yes, keesiemeijer that's exactly what it was. A function filtering the output of wp_list_categories(). I missed it on the first pass because of spaghetti code.

    Thank you for your support, much appreciated!

Reply

You must log in to post.

About this Topic