• Resolved sgchan

    (@sgchan)


    For some strange reason, the get_categories function will not work if I add a parent or child_of parameter. I have verified that the parent id is captured in the wp_term_taxonomy table. When I do a generic var dump on get_categories, the parent and category_party arrays are empty, i.e. ['parent']=>int(0) and ['category_parent'=>int(0).

    Any clues on how I might be able to troubleshoot? Is this a WordPress bug? Or something else is messing up the environment?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’ve not noticed any aberrant behavior. What is your actual get_categories() call? Other args could add in terms that do not have the requested parent property. Parent property of 0 indicates a top level term.

    Other code could be inadvertently altering the query through filtering. If you’re sure any of the returned terms should not be there, try deactivating all plugins and switching to twenty twenty-one theme. Temporarily place your test code on an appropriate theme template.

    Thread Starter sgchan

    (@sgchan)

    Thank you for your hint. I turned off the plugins and back on one at a time and was able to pinpoint the culprit.

    Thank you very much

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_categories acting weird’ is closed to new replies.