A recent project saw adopt the Vertex Elegant Theme which comes with a pre-built set of custom posts to create diverse content. The theme has 3 built-in custom posts:
- Team Member
- Project
- Testimonials
The requirement from the client is to use the theme for an online magazine. They have a group of editors and authors working on the current issue, with various sections to the magazine.
So the challenge was 2-fold:
- Integrate the theme with as little modification as possible in order to keep the cost down
- build a back-end dashboard which brings clarity to the complex work of putting together an issue with several articles, several sections and various authors contributing to it.
So working around the idea of each article being a post, each being in a given section of the magazine (a post category) and at the same time being able to connect to past issues with keywords (or post tags), we wanted to dissociate the current issue from past issues so as to confuse the editors and authors when editing posts.
We also wanted to reuse a common set of keywords to connect old articles new ones.
We achieved this by by reusing the main Posts that comes with the default installation of WordPress as the Past Issues of the magazine.
We then changed the Project custom post of the Vertex theme to manage the current issue.
And since we were using the registered users to display the editorial team details, we decided that we did not need the Team Member custom post that was automatically installed with the Vertex theme.
All in all we need to do the following custom coding:
- rename default Posts to Past Issues,
- change the Category labels to Sections
- rename the custom post Project to Current Issue
- share the default Tags taxonomy between the Past Issues and the Current Issue
- rename the Tags label to Keywords
- and finally add a Keywords sub-menu to the Current Issue Menu.
Here is how we went about it…
The WordPress challenge….
The challenge above is relatively straightforward when one knows what to change, the real challenge is to actually to find what to change.
This is what this post is all about as I try to drop little white stones on my exploration of the WordPress jungle so-to-speak.
Changing menus
My first clue came from the answer provided to someone’s question along similar lines about changing menus in the dashboard. However, it wasn’t sufficient to give me an overview of the logic behind the answer. So I went about digging further, but the only things I could find where wordpress codex functions on adding/removing menus and nothing on changing the name.
Modifying the functions.php
add_action( 'admin_menu', 'sy_change_admin_menu' );
function sy_change_admin_menu() {
global $menu;
global $submenu;
//let-s remove the team-member post_type menu
remove_menu_page( 'edit.php?post_type=team-member' );
//let's add the tags sub-menu to the post_type projects
register_taxonomy_for_object_type( 'post_tag', 'project' );
add_submenu_page( 'edit.php?post_type=project', 'Keywords', 'Keywords', 'manage_categories', 'edit-tags.php?taxonomy=post_tag', '' );
//project post_type renamed to Current Issue
$menu[26][0] = 'Current Issue';
$submenu['edit.php?post_type=project'][5][0] = 'All Articles';
$submenu['edit.php?post_type=project'][15][0] = 'Sections'; // Change name for categories
//post post_type renamed to Past Issues
$menu[5][0] = 'Past Issues';
$submenu['edit.php'][5][0] = 'All Articles';
$submenu['edit.php'][15][0] = 'Sections'; // Change name for categories
$submenu['edit.php'][16][0] = 'Keywords'; // Change name for tags
echo '';
}
The codex has a section the admin menus hooks which is what the above answer is using, but I was intrigued about the reference to the the global $menu
and $submenu
objects. So I devised a small function to explore the structure of these objects as an empirical guide to modifying the dashboard menu.