Support » Fixing WordPress » get_categories function not working as expected

  • Resolved TillS

    (@tills)


    Hello,
    I have a problem with the function get_categories.

    When I set the argument “taxomy” to array(‘custom_tax’, ‘category’) the function only returns terms from the default category and not from the custom_tax. When I set the argument to array(‘post_tag’, ‘category’) it returns terms from post_tag and category. When I only use my custom_tax it returns all terms from my custom taxonomy.

    Why does it not work with custom taxonomies and the default category? I tried get_terms as well, with the same outcome.

    Here is my code:

    $args = array(
    		'hide_empty'               => 0,
    		'hierarchical'             => 1,
    		'taxonomy'                 => array('category', 'custom_tax'),
    	);
    
    	$postCats = get_categories( $args );

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Strange, it seems to work for me in WP 3.9.2, theme Twenty Ten.

    Perhaps a plugin or your theme is interfering.

    Thread Starter TillS

    (@tills)

    Thanks! You were right, the multilanguage plugin WPML was interfering. I had to make the custom taxonomy translatable via the plugin. Then it worked.

    Thread Starter TillS

    (@tills)

    closed

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get_categories function not working as expected’ is closed to new replies.