Posts tagged: tags
The Difference Between Taxonomies, Categories, and Tags (Oh My!)
A common question for new WordPress users is, “what’s the difference between categories and tags?” Like everyone knows what a “category” is, but the idea of “tags” can seem very similar. And then you throw in related WordPress concepts like “taxonomy”, and things can get confusing very quickly. But no worries, it’s really not that complicated. Let’s break it down..
How to Check if Post has Taxonomy Term
Something I did not know about when working with Custom Post Types and Custom Taxonomies. Normally when checking if a regular WP Post belongs to a specific category, we can use the WordPress function in_category(). But that does not work with Custom Post Types. To check if a CPT belongs to a specific term in a Custom Taxonomy, use has_term() instead.
WordPress Post Navigation Redux (New Tags!)
For years WordPress post navigation has been possible thanks to a flexible set of five functions, including posts_nav_link()
, next_post_link()
and next_posts_link()
. These navigational functions continue to work great in many WordPress themes, but there are newer, even more flexible functions available to theme developers. Introduced in WordPress 4, these new navigation functions can make it easier than ever to display nav links for your WordPress-powered posts.
Rounded Font-Sizes (with Colors!) for Tag Clouds
Tag clouds accomplish their varied font sizes by applying inline styling to each tag. The resulting font sizes can be really weird with values like font-size: 29.3947354754px;
.
Of course, there is nothing inherently wrong about that, but it feels a bit unsettling and less controllable. Awesomely, Mike Summers sent in a solution he uses on his own site..
The Difference Between is_singular() and is_single()
With WordPress, there are various distinct types of page views. For example, there are category-archive views, tag-archive views, author-archive views, date-archive views, single-post views, single-page views, and so forth. And of course you know that you can target single-post views in your theme template with the conditional tag, is_single()
:
Definitive Guide to WordPress Post/Page Navigation
There are many ways to navigate a WordPress-powered site. There are archive links, category links, page links, internal post links, single post links, admin comment links, tag links, and many other types of navigational links. When it comes to navigating sequentially through your site’s chronological archive pages, category archives, and other types of archive pages, WordPress provides several useful template tags designed to dynamically link the pages together. Likewise, for single permalink post-views, WordPress provides a set of template tags that connects the pages together in chronologically sequential fashion.
Advanced WordPress Targeting with body_class_plus()
Since WordPress 2.8, we can target specific types of page views with CSS using the new body_class()
tag. Designed for use within the <body></body>
element, body_class()
outputs various class attributes according to the current type of page view. This makes it easy to apply page-specific styling such as current-page navigation highlighting and other nifty CSS tricks.
Awesome Image-Attachment Recipes for WordPress
Recently, I found myself on the front lines of WordPress’ somewhat complicated Media-Library system. The site that I was developing required a rather elaborate system of retrieving and displaying image attachments. So, using the latest version of WordPress (2.8.3 at the time), I found myself experimenting with as many template tags and custom functions as I could find. After much experimentation, I discovered the perfect solution, and along the way I collected a healthy collection of recipes for displaying image attachments and their various types of associated information.
Delicious Recipes for WordPress Page Menus and Page Listings
There are so many awesome ways to display your WordPress pages. Out of the box, WordPress provides two different template tags for displaying lists of your site’s pages. The first, most-commonly used tag is wp_list_pages()
, and the second, lesser-known tag is wp_page_menu()
. First we’ll explore the highly flexible wp_list_pages()
template tag, and then we’ll dig into the new wp_page_menu()
tag. Along the way, we’ll check out some delicious recipes, tips and tricks for creating the perfect WordPress Page Menu.
Add/Remove Buttons from WordPress Write Panel
One of the features of WordPress 2.8 was a “increased speed of the Admin area”, which cited compressed JavaScript files as the reason for the speed increase. One of those files that was compressed was the file quicktags.js
in the /wp-includes/js/
directory.
Custom WordPress Title Tags
By default, WordPress provides a decent way of including <title></title>
information for your posts, pages, and various archive views. This is important for usability and for better SEO. Most themes ship with some sort of title functionality baked right in, but for those that don’t, you can add titles easily using WordPress’ wp_title tag. Using wp_title()
, we can specify several useful parameters, including: