This adds one Font Awesome icon to each list item in the WordPress Categories template tag, “wp_list_categories”. (The same icon will be applied to each list item.) This is done using a filter function which should go in a functions file. This example adds the “checkered flag” icon. You can choose your own icon from … Read more →
Posts Tagged “WordPress categories”
On a single post or singular page, you get the permalink like: Get the permalink for a custom post type archives page: Get the permalink for a custom taxonomy page: Usage If you use social media open graph tags, then you’ll recognize this which takes the permalink of any current page: This will not work … Read more →
This code will get the related posts of the current custom-post-type single post being viewed. This will get posts only of the same custom post type and the same category of the current single post. Obviously, this only works for your custom post type if you gave it support for ‘category’ when you registered it. … Read more →
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 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.
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 →
These template tags must be used within the loop, unless otherwise indicated. Some of these tags can be used outside the loop if on single.php, cateogory.php, or archives.php, when indicated below. Display the value of a custom metabox field, in which ‘key’ is your custom meta key: The Title of a Post linking to its … Read more →
Show a loop of related articles on the sidebar of single.php (or any single post template sidebar), but exclude the current single post from the related loop. This code goes in the sidebar of a single template file of a WordPress theme. Related articles, for this code, are posts within the same category of the … Read more →
You want to use a different single template file for only one category in WordPress. First, create the special single template file. Name it whatever you want. Next, open your theme’s single.php. At the very top of single.php, before the head, insert this: In the code above, you must make change ‘the-special-cat-slug’ in line 1 … Read more →
If you’re making your own WordPress theme or template, sometimes you need to show something different for posts of one specific category. You may want to display different text or a different picture (within the loop), or even call a different header or different template file altogether (outside the loop) for a certain category. This … Read more →