2

I am using the following to display all the categories from my custom post type. How can I edit it so instead of having the output of the categories in <ul><li> elements it has <a href .... instead? I need to edit the output of wp_list_categories( $args );

<?php $customPostTaxonomies = get_object_taxonomies('video');

if(count($customPostTaxonomies) > 0)
{
     foreach($customPostTaxonomies as $tax)
     {
         $args = array(
              'orderby' => 'name',
              'show_count' => 0,
              'pad_counts' => 0,
              'hierarchical' => 1,
              'taxonomy' => $tax,
              'title_li' => ''
            );
            echo '<span class="tags-button" style="list-style:none; float:left;">';
         wp_list_categories( $args );
         echo '</span>';
     }
} ?>
3
  • 1
    On the $args, add another parameter - 'style' => 'simple'
    – Shazzad
    Commented Jan 5, 2014 at 17:39
  • @Shazzad That worked but how would i remove the BR it generates after each category? Commented Jan 5, 2014 at 18:19
  • Answered below.
    – Shazzad
    Commented Jan 5, 2014 at 18:33

1 Answer 1

2

You will need to use style parameter to define the type of list. And to remove <br /> tags from the list, set parameter 'echo' => 0 and str_replace to remove <br /> tag from the output.

$args = array(
    'orderby' => 'name',
    'show_count' => 0,
    'pad_counts' => 0,
    'hierarchical' => 1,
    'taxonomy' => $tax,
    'title_li' => '',
    'echo' => 0,
    'style' => 'simple'
);

echo '<span class="tags-button" style="list-style:none; float:left;">';
    echo str_replace( '<br />', '', wp_list_categories( $args ) );
echo '</span>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.