New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Advanced custom post type functionalities

From: Create an Online Portfolio with WordPress

Video: Advanced custom post type functionalities

One of the really cool things about custom post types is that you can define what kind of functionalities they support. That way you can customize your custom post types to only ask for the kind of info you want and you can shape it to fit with the content you want to display. You can get pretty advanced with this stuff, but in this course I will spare you to madness and show you the standard functions and how to call them. All of this is done in an array placed in the supports variable. So if we look at the recipes, custom post type, when we scroll down a bit, you'll see we have this variable called supports.

Advanced custom post type functionalities

One of the really cool things about custom post types is that you can define what kind of functionalities they support. That way you can customize your custom post types to only ask for the kind of info you want and you can shape it to fit with the content you want to display. You can get pretty advanced with this stuff, but in this course I will spare you to madness and show you the standard functions and how to call them. All of this is done in an array placed in the supports variable. So if we look at the recipes, custom post type, when we scroll down a bit, you'll see we have this variable called supports.

And in the array, it says title, editor, and comments. If we go to the site itself and create a new recipe, you'll see we have a title, the editor, which is this area, where you put the regular content and comments, and comments is basically just the ability to turn comments and trackbacks on and off. What if we want to add some additional functionality to it? Well, there is a whole bunch of functionality we can add if we want to. So if you go to your code snippets, you see I have added the supports variable with a long array of content.

You can simply copy the whole thing and paste it in, in place of what is already there. I'll take away the comma for now and then we'll read it. The supports array says title, here is the title, the editor, and the author. We already have that, but in addition, it now says thumbnail which is the post thumbnail or featured thumbnail that we have in each post. It also says excerpt, which is the excerpt you can write if you want to, and of course we have comments and then also custom-fields. So you can new custom fields.

If we save this and go back to our editor and just reload the page, you will see that in addition to the title, editor, and comments, we now also have Featured Image here on the side, where you can add a new featured image. We have Excerpt, where you can add an excerpt. We have Custom Fields, Discussion and also Author, where you can define who wrote this. If you have multiple authors you can assign a different author to your content.

You can also add another variable at the end here, so if you say comma and then go down a line, you can add another variable called has_archive. Then give it an archive-name. So I'll copy that and paste it in. Now I'll just space it with equal. Now this has_archive variable is something we will come back to later. But for now, I will just say the archive -name as recipes, and leave it at that.

The reason why you have this has_ archive value is because later on we'll create an index page just for the recipes post type, and that recipe page has to have a name. So this name, has_archive name, actually defines the name of the index page. But like I said, we'll get back to that later. Now that we've added this supports array and the has_archive, to the recipes post type, we want to add it to all the other ones too. So I will simply go here and copy these two lines of text, copy it, scroll down until I find the same call inside the photos, custom post type, paste the old one in, and then change has_archive to photos, and I will scroll down and do the same for videos.

So here is the support. Paste it in and change to videos. And I now save it and go back to my editor, you will see when we create, a new Photo, we now have Featured Image, Excerpt, Custom Fields, Discussion, and Author, and the same for Add new video, Title, Editor, Excerpt, Custom Fields, Discussion, Author, Thumbnail.

If you want to make sure you have exactly the same thing I have, again you can go into the code-snippets and copy out the full code for posttypes.php and just paste it in and place it what you currently have and you'll end up for the exact same thing I have right now. By adding different functionalities to different post types, you can customize your post types to fit with the content you want to display. It's another simple way of making your site easier to administer and it gives you complete control over your content.

Show transcript

This video is part of

Image for Create an Online Portfolio with WordPress
Create an Online Portfolio with WordPress

40 video lessons · 28113 viewers

Morten Rand-Hendriksen
Author

 
Expand all | Collapse all
  1. 6m 28s
    1. Welcome
      58s
    2. Using the exercise files
      3m 54s
    3. Using the code snippets file
      1m 36s
  2. 8m 31s
    1. What is an online portfolio?
      2m 43s
    2. Tour of the finished project
      3m 15s
    3. Setting up a WordPress development environment
      2m 33s
  3. 16m 10s
    1. Creating site architecture
      5m 1s
    2. Creating a child theme
      6m 7s
    3. Creating an external file to manage functions separately from the theme
      5m 2s
  4. 25m 26s
    1. What is a custom post type?
      2m 14s
    2. Setting up a custom post type
      6m 39s
    3. Adding advanced variables to the custom post type
      3m 35s
    4. Advanced custom post type functionalities
      4m 29s
    5. Changing the menu position of the custom post type
      3m 19s
    6. Adding a custom post type icon
      5m 10s
  5. 22m 8s
    1. What are custom taxonomies?
      3m 34s
    2. Setting up a basic custom taxonomy
      2m 52s
    3. Hooking a custom taxonomy to a post type
      3m 13s
    4. Adding advanced variables to a custom taxonomy
      3m 9s
    5. Using hierarchical and nonhierarchical custom taxonomies
      5m 54s
    6. Using custom taxonomies in admin
      3m 26s
  6. 25m 40s
    1. Populating content into the custom post types
      10m 54s
    2. Uploading videos to YouTube
      2m 22s
    3. Embedding YouTube videos in a custom post type
      4m 23s
    4. Uploading videos to WordPress
      8m 1s
  7. 39m 47s
    1. Creating custom post type templates
      6m 50s
    2. Adding taxonomy info to the custom post type template
      9m 13s
    3. Creating conditional custom taxonomy links
      4m 46s
    4. Handling multiple post type templates: Individual templates
      6m 25s
    5. Handling multiple post type templates: Consolidating everything in one file
      6m 21s
    6. Handling multiple post type templates: Making custom post types the default
      6m 12s
  8. 15m 23s
    1. Creating an index page for a custom post type
      8m 10s
    2. Creating a custom taxonomy index page
      7m 13s
  9. 12m 3s
    1. Creating a custom footer sidebar template
      6m 58s
    2. Displaying a list of links to the latest custom post type posts
      5m 5s
  10. 14m 58s
    1. Creating static pages for the front and the blog
      4m 54s
    2. Populating the menu with new index pages
      4m 52s
    3. Creating a contact page with a contact form
      5m 12s
  11. 5m 55s
    1. Including the abstraction layer in other stock themes
      5m 55s
  12. 1m 22s
    1. Next steps
      1m 22s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.