• Resolved ALDesigner

    (@aldesigner)


    I’d like to make a list of links using wp_list_categories() for the custom taxonomies I created with CPT UI. I’ve tried approaches explained in roughly seven different articles, all to no avail.

    Example of one of the approaches I attempted:

    <?php
    
    				$customPostTaxonomies = get_object_taxonomies('awards');
    
    				if(count($customPostTaxonomies) > 0)
    				{
    					 foreach($customPostTaxonomies as $tax)
    					 {
    						 $args = array(
    							  'orderby' => 'name',
    							  'show_count' => 0,
    							  'pad_counts' => 0,
    							  'hierarchical' => 1,
    							  'taxonomy' => $tax,
    							  'title_li' => ''
    							);
    
    						 wp_list_categories( $args );
    					 }
    				}
    
    			?>

    Is there a specific, recommended approach when using CPT UI?

    https://wordpress.org/plugins/custom-post-type-ui/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    We don’t do anything special to taxonomies or post types that would limit how you use them in any other function/query that is available to WordPress. We’re doing the equivalent of running register_post_type() and register_taxonomy() for you with the settings chosen or default values.

    If nothing from the code above is being displayed, then it sounds like the issue may be that $customPostTaxonomies is empty, or some part of your arguments aren’t returning anything.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Out of curiosity, do you have taxonomy terms assigned to publish posts yet? By default, it’s set to hide empty terms, unless you set ‘hide_empty’ to false

    Thread Starter ALDesigner

    (@aldesigner)

    At present, yes. I have only created one custom taxonomy as of yet, and I’ve assigned it to all of my test posts.

    Thread Starter ALDesigner

    (@aldesigner)

    Just used this just to see the output:

    <?php
    
       $taxonomy_names = get_object_taxonomies( 'post' );
       print_r( $taxonomy_names);
    
    ?>

    Got this:
    Array ( [0] => category [1] => post_tag [2] => post_format )

    Then tried:

    <?php
    
       $taxonomy_names = get_object_taxonomies( 'awards' );
       print_r( $taxonomy_names);
    
    ?>

    Got this:
    Array ( )

    Awards is the custom taxonomy that I created that the test custom posts are associated with.

    Thread Starter ALDesigner

    (@aldesigner)

    I was able to get it to work by renaming the custom taxonomy. I was unaware that having a “-” in the name would interfere with using it as an argument within wp_list_categories().

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Looks like it’s not getting attached properly, with those results.

    Are you willing to let me log in and see things first hand?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Displaying custom taxnomy link list using wp_list_categories’ is closed to new replies.