Web & Software Developer

Posts Tagged “WordPress categories”

Add Glyphicons to wp_list_categories

Add Twitter Bootstrap Glyphicons to individual list items in wp_list_categories. Do this by modifying the wp_list_categories. Easy peasy by adding a filter. No forsaken Walker needed. My example below adds the ‘icon-book’ glyphicon to each list item generated by wp_list_categories. For all the possible icons you can choose from, see the Twitter Bootstrap stylesheet (bootstrap.css).

Get Top Level Parent Category Id Of a Single Post

Get the top level parent category ID of the single post being viewed on single.php. Works on single.php. Step 1 Requires this function. Place it in your functions.php or other function file. Step 2 – Usage Use this in single.php to get the category id of the top level parent category.

Conditional Statement For a Custom Taxonomy

In a WordPress template, sometimes you want to do something only for one single term of custom taxonomy, not for all posts using the custom taxonomy. For example, say you’ve created a custom taxonomy, ‘Fruits’ and it has some terms: bananas, oranges, apples. And say you want to do something only for posts that have … Read more →