Develop

WordPress: Rename Default Category Taxonomy

After my post on Renaming the default “Posts” post type in WordPress to something else, I’ve gotten some follow up questions on renaming taxonomies as well. Here is a quick tutorial on how you can rename the default WordPress taxonomies (tags/categories).

Solution

Similar to renaming the post type, we need to tackle two areas: the menu item label, and the post object labels. In this example, I’m going to rename the default “Category” to “Authors”. You can rename “Category” to anything you want, just replace every instance of Author/Authors in my code below.

Changing Admin Menu

First, let’s rename the menu item in the WordPress admin. You can copy this code into your functions.php file, or into a custom functionality plugin.

function revcon_change_cat_label() {
	global $submenu;
	$submenu['edit.php'][15][0] = 'Authors'; // Rename categories to Authors
}
add_action( 'admin_menu', 'revcon_change_cat_label' );

Note: to apply these changes to tags, use $submenu['edit.php'][16][0] = 'Author Tags';.

Changing Object Labels

Next, let’s update the other labels throughout the admin (meta boxes etc.), you can paste this code directly below the code for renaming the menu label.

function revcon_change_cat_object() {
	global $wp_taxonomies;
	$labels = &$wp_taxonomies['category']->labels;
	$labels->name = 'Author';
	$labels->singular_name = 'Author';
	$labels->add_new = 'Add Author';
	$labels->add_new_item = 'Add Author';
	$labels->edit_item = 'Edit Author';
	$labels->new_item = 'Author';
	$labels->view_item = 'View Author';
	$labels->search_items = 'Search Authors';
	$labels->not_found = 'No Authors found';
	$labels->not_found_in_trash = 'No Authors found in Trash';
    $labels->all_items = 'All Authors';
    $labels->menu_name = 'Author';
    $labels->name_admin_bar = 'Author';
}
add_action( 'init', 'revcon_change_cat_object' );

Note: to apply these changes to the tag taxonomy, change:
$labels = &$wp_taxonomies['category']->labels;
to…
$labels = &$wp_taxonomies['post_tag']->labels;

Conclusion

This code provides a quick, simple adjustment to the WordPress admin that can be very intuitive for clients and users! It’s always best to call something what it is, or at least what it’s intended to be used as, so that you have a seamless UX and aren’t spending all day providing client support ;)

Develop

WordPress: Add current_page_ancestor Class to Custom Post Type Menu Item

The Issue

Family Tree

fig 1.0 family tree

Let’s say you just registered a Custom Post Type in WordPress called “products” and have added the CPT archive page to your site’s main menu. If you’ve styled your menu to react to the .current_page_item class, then you will see the menu item change when you are at www.yoursite.com/products. This is the expected behavior and everything is working!

However, if you were to navigate to a single post within the Custom Post Type, there is no class on the parent menu item to allow you to target it if you wanted to add styles. In my case, I like to keep the parent item highlighted, so if someone is viewing www.yoursite.com/products/product-1 it makes sense to me that “Products” in the main menu would remain highlighted – the site visitor is STILL technically viewing products!

Read More

Develop

WordPress: Designing a Custom Page Template (Part 2)

What’s in this Tutorial

This is Part Two of a three part tutorial on creating custom page templates for WordPress. In this tutorial I will be covering the process of translating design into code for a page template. We will take a look at:

  1. Planning the markup based on the design.
  2. Coding the layout into HTML and adding responsive classes (based on the grid included in the Bones Starter Theme).
  3. Adding our dummy content and any additional CSS.

Click here to read Part 1: Designing a Custom Page Template

Read More

Develop

BuddyPress: Send Admin Notification when User Updates Extended Profile Fields

Background

I wrote a similar post explaining how to send an email notification from WordPress when standard and custom profile fields are updated. A commenter on that post was asking if this was possible with the extended profile fields that you setup in BuddyPress. Well, of course anything is possible…it’s just a matter of figuring it out ;)

Read More

Develop

WordPress: Send Admin Notification when User Updates Specific Profile Fields

Background

I’ve had some requests in the past from clients who want to be notified when WordPress users change information in their user profile, easy enough for the most part. However, a recent client asked to be notified when specific information was changed, mainly, contact related info. This would include their email address, their phone number and their mailing address. No big deal, or so I thought…

Read More