Remove “View all posts filed under” from wp_list_categories Title attribute
Remove the menacing “title” attribute from all elements under the wp_list_categories() function.
TweetWordPress automatically includes the Title attribute for each element in the wp_list_categories() function. It looks pretty bad when it you’re implementing the category list in a place like the top navigation menu.
1 | wp_list_categories(); |
Here is a way to take off the “Title” attribute from wp_list_categories(). wp_list_categories has a parameter echo [like many other wp functions], which when set to 0 does not echo the code onto the screen. This way, we can get the whole string onto a php variable.
To change Title attribute to “Category Name” instead of “View all posts filed under Category Name” :
1 2 3 | $categoriesVar = wp_list_categories("echo=0"); $categoriesVar = str_replace( "View all posts filed under " , ' ' , $categoriesVar ); echo $categoriesVar; |
To completely remove the title attribute:
1 2 3 | $categoriesVar = wp_list_categories("echo=0"); $categoriesVar = preg_replace( '/title=\"(.*?)\"/' , ' ' , $categoriesVar ); echo $categoriesVar; |
The same code can also be written in a single statement:
1 2 | echo preg_replace('/title=\"(.*?)\"/','',wp_list_categories("echo=0&title_li=")); /* Strips off Title attribute from wp_list_categories */ |
Update: Feb 08, 2010
WordPress checks for the category description before it defaults the title to “View all posts filed under “. So, you could just add a single whitespace as the description of categories to not show anything in the title.
- Thanks to Justice Chad for this.
Was this post useful? Share on Twitter or Facebook and spread the love.
Related Posts
- Make URLs within posts clickable
- How to remove the WordPress Admin Bar
- Fix “Is its parent directory writable by the server?” error for WordPress Image uploads
Below is a list of possibly similar posts, as suggested by six huge golems hired to do just that.
Now What?
- Tweet this It's been long since you tweeted
- Ask Got a query you want us to answer?
- Spread the love Share it socially
Finished reading? Wondering what to do? Heres a hint. Here are some suggestions just for you