Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So far we've created three new post types, we've changed the labels of those post types so they display the right names for each of the post types and we've added a lot of functionality to each of the post types, but there are still a few things that we need to do to make this a complete project. First of all when you look at the new post types you notice they appear at the very bottom of this first section of the menu. So you have Posts and they have Media, Links, Pages, Comments, and then you have got the post types. What you want to do is probably move these post types up so they appear underneath Posts rather than underneath Comments.
We can do that with one of the variables that's inside the post type definition. If we go back to posttypes.php and scroll down, you'll see that in the arguments array for each of the register post type functions there is a variable called menu_position. It's right here, and it's always set to null by default. If it's set to null it will always appear on the bottom of the first main part, so under Comments, and then each of the post types will appear as they appear inside the functions.php file or in our case the posttypes.php file.
If we want to change that, we can change this null to an actual number. Now there is a reference scale for this and I'd put it into the code-snippets file so you always know what's going on. What you see here is menu_position and it's set to 5 because I want it to appear directly under Posts, but as you can see from this list you can set it to 0 where it appears at the very top, you can set it to 10 or just below Media, 15 below Links, 20 below Pages, 25 below Comments, etcetera, etcetera, all the way to the bottom.
So depending on what number you give menu position, the items will appear underneath or above each other. So if we go back to posttypes.php and for recipes we set the menu_position value to the number 5 and save the file. When we go into admin you'll see that Recipes, which is currently down here, will move up directly under Posts. So now we have Posts, Recipes and then Media, Links, Pages, Comments, etcetera, and if we do this same for Photos and Videos, we can get them to appear directly underneath too.
For them we can either go and set each of the values just to 5 or if we want them to appear in a certain order, you can for example set recipes to 4, photos to 5, and then videos to 6, or you can set videos to 4 and it would appear over recipes, but I'll set them all to 5 for now, reload the page, and you'll see the structure now makes a lot more sense. We have Posts, Recipes, Photos, and Videos at the very top.
It's a subtle change but it's again one of those changes that makes a huge difference, because it tells the user something about the priority of content. Now Recipes, Photos, and Videos have become first level citizens of the site rather than being afterthoughts that are stacked underneath Comments. By changing the menu position of your custom post types you're taking control not only over what kind of content can be published, but also what is more important on the site. It's a subtle distinction, but one that makes a lot of difference.
Get unlimited access to all courses for just $25/month.Become a member
120 Video lessons · 64601 Viewers
119 Video lessons · 71886 Viewers
125 Video lessons · 32500 Viewers
84 Video lessons · 18977 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.