Tagged: category

Code Snippet NameSort by Category CategorySort by Category Submitted BySort by Person   Date

WordPress Check If Current Category Has Children

Wordpress 04/26/11
This handy snippet will tell you whether or not a the current category archive page you are viewing has child categories. This was used in a situation where there were a lot of categories with children and the site was only to show posts at the end of the line. In the middle it just showed a ... View Code

Tags , , ,

SQL Count Posts in Category

Wordpress 02/25/11
This was yet another tough one to figure out, but worth it. This custom query allows you to count the number of private posts in a category. Its easy to count published posts using a variety of wordpress template tags but there was no easy and lightweight way to pull it off that I could find. ... View Code

Tags ,

Refine search by category

Wordpress 11/22/10
Use this snippet to add functionality to the default wordpress search form. First, edit your search.php file and add the first snippet above the wordpress loop. Then copy and paste the search form within your template files wherever you want to display the form. View Code

Tags ,

Post count in a category

Wordpress 07/18/10
This retrieves the number of posts in category 5. This wordpress function is very handy. Show how many posts you have in a specific category. If you have parent categories you can use their id to get parent category post totals. View Code

Tags

Create category term

Wordpress 06/16/10
Here is a snippet to create a new category in wordpress, I could not get the wp_create_category() function to work in my plugin so I used this instead. It creates the category manually using the wp_insert_term() function. View Code

Tags , ,

Category Exists

Wordpress 06/16/10
This is a wordpress function that checks if a category exists in your wordpress install. Simply call the function and pass the category slug/name. It returns true(1) if the category does exist. View Code

Tags

Exclude cats from the_category()

Wordpress 03/29/10
This function adds to the wordpress function the_category(). Basically it allows you to exclude categories from that function. Add the snippet to your functions.php file.

Call this funtion just like you would call the_category but use this: <?php incomplete_cat_list(', '); ?> View Code

Tags ,

Category ID and Name List

Wordpress 03/26/10
Add this to your wordpress functions.php file to create a list of categories and their id's in the wordpress dashboard. This is great for developers and helps to keep custom pages in line, like category-21.php View Code

Tags ,

Current Category Id Function

Wordpress 03/07/10
A function to get the current category ID. This function will retreive the current category ID number. View Code

Tags , ,

Sidebar category highlighting

CSS 03/04/10
This set of css rules creates a highlight effect for the current category in Wordpress. The sidebar widgets that display blog categories can be highlighted when you are on the page that corresponds with that category. View Code

Tags , ,

Category and Post ID worksheet

Wordpress 03/03/10
This worksheet explores a few Wordpress functions concerning post and category ID numbers. There are a few ways to find out the ID number of your current category or post. Only certain functions work outside the Wordpress Loop, these are commented as 'In and Out'.

The 'cat_is_ancestor_of' ... View Code

Tags , , ,

Count posts in a category

Wordpress 03/01/10
Use this wordpress snippet to get a count of posts in a category. View Code

Tags , ,

Exclude category from search

Wordpress 02/26/10
This very helpful function, the query_posts function, rules. Put this code just before the wordpress loop to exclude a category from the search results. View Code

Tags ,

Display current category name

Wordpress 02/20/10
This snippet displays the current category in wordpress. Paste this code into the archive.php file above the wordpress loop, it will display the name of the current category on the page that is served.

The 'false' argument prevents echo of the value, true will display the category ID number. View Code

Tags

Get current category ID

Wordpress 02/13/10
This snippet gets the current category in wordpress. I use this within the archive.php file to add functionallity.

Say you want to have a special message at the top of the archive page for the category you call 'My Coins' which is cat ID=110. You can use the above script and a conditional that ... View Code

Tags ,