Try this (tested) code below. I believe the issue was the passing of the $post_type
parameter to get_object_taxonomies
(i.e. you passed it in quotes as '$post_type'
. If uncomment the two var_dump
‘s you’ll see what information is outputted.
<?php
$postargs = array(
'public' => true,
'_builtin' => false
);
$post_types = get_post_types( $postargs, 'names', 'and' );
// Main Loop Start
foreach ($post_types as $post_type){
//var_dump($post_type);
$taxonomies = get_object_taxonomies($post_type, 'objects');
foreach ($taxonomies as $taxonomy){
//var_dump($taxonomy);
// Do Stuff with taxonomy here
}//foreach taxonomy
}//foreach post_type
?>
Note: I’ve tested this with custom post types registered by a theme, but not with custom post types registered by plugins, but this should work for those too