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

Including the abstraction layer in other stock themes

From: Create an Online Portfolio with WordPress

Video: Including the abstraction layer in other stock themes

At the very beginning of this course I mentioned that if you add custom post type and custom taxonomies to your functions .php file, they follow with the theme. That also means if they're not included in the new theme you choose to activate, they won't show up, which is why we created the abstraction layer in the very beginning of the course. Moving the functions for the custom post types and custom taxonomies out of the functions.php file and into separate file it could reference. So how do you use the abstraction layer in a different theme? The same way you did for this theme. Let's see how that's done.

Including the abstraction layer in other stock themes

At the very beginning of this course I mentioned that if you add custom post type and custom taxonomies to your functions .php file, they follow with the theme. That also means if they're not included in the new theme you choose to activate, they won't show up, which is why we created the abstraction layer in the very beginning of the course. Moving the functions for the custom post types and custom taxonomies out of the functions.php file and into separate file it could reference. So how do you use the abstraction layer in a different theme? The same way you did for this theme. Let's see how that's done.

I'll go to my Dashboard and find a new theme. So I'll go to Appearance then select Themes and from here I can click Install Themes to find a new theme to install. So I've already found a theme that you might find interesting to work with because you're making a portfolio and it's called Showcase, so we'll search for that and here it is. It's at very beginning. So we'll click Install to install the theme and Install Now and WordPress now installs the theme for me. Now I can activate this theme and you'll notice what happens. Pay to attention to the sidebar here.

With a new theme activated you see we're now back to the default Post, Media, but all our Recipes, Photos, and Videos are gone. That's because this theme does not have the reference to our post types file. So what I'm going to do now is create a new child theme. I'll refresh my themes folder so I can see the new theme. Here it is, Showcase, and now I can create a new child theme to go with showcase. The reason why I'm creating a child theme rather than altering the parent theme is because if the new update of Showcase becomes available and I upgrade Showcase from within WordPress any change I make to Showcase will be gone, because it'll be overwritten by the new update. Whereas if I create a child theme that child theme will exist even if Showcase is updated.

So I'll create a new folder, call it something like myShowcase, and within that folder I'll first create a new CSS file called style.css, and then within this file, after deleting all the content, I'll place that code that defines this as a new child theme of Showcase. So I'll go to the code snippets and here under 10.01, you'll find all the code necessary, so I'll copy it and pasted in. Here you see it says, import url ParentThemeFolder/Style. I made this generic, so you can do it with any theme.

So here I'm just going to insert the name of the parent theme folder, which is showcase and then I'll give it a new name, so I'll call it New Showcase Child Theme, and I could give it a description if I wanted to. I should always put in the author and reference the original author. And finally down here my template, I put in the parent theme folder again, so showcase. This, if you remember, is what defines what the parents theme is.

When I'll save this and go back to WordPress Admin and reload the themes page, the new child theme appears. Here it is, New Showcase Child Theme, and I can activate it. We still don't have the custom post types on the side here, but if I reload the homepage, you'll see we have a new theme applied. Now I'm going to includes the custom post type as well. So I'll go back to my code editor and under the myShowcase folder, I'll create a new file, this time a PHP file, and I'll call the functions.php and within the function.php file all I need to do is reference this post types file.

So I'll go back to my code snippets, find that code, includes_once(ABSPATH . 'wp-content/themes/posttypes, paste it in and end my PHP delimiter, save it and when I go back to my Admin panel and reload it, we now have Recipes, Photos and Videos, just like before. And if we go check inside them, you'll see that all my content is also still there. So it didn't disappear.

It just was hidden. If I now go to my front page I can visit Recipes and Photos and Videos and see the content. Now of course because this is a new theme I'm working with, I still have to make all those other changes. Like for instance I have to make a new index page so it doesn't say from the blog, but says recipes and I have to go through the same process that we've gone through with twentyeleven. But the core items, the custom post types and custom taxonomies, are on the site now and we can work in our new child theme to make this site look exactly the way we want it to.

The reason why I chose this showcase theme as the new parent theme is because it has a lot of cool features that you might want to use when you create your online portfolio. So I suggest if you have completed this course using twentyeleven and you've tested all the features in twentyeleven and you're not fully satisfied with the design, you might want to take a look at this theme instead and do the process again using Showcase instead. Of course as you have seen, in addition to adding the abstraction later to your functions.php file, you need to do a bit more work to display the content properly.

Most notably, you should always create custom post type templates for single view and index pages and also make a taxonomy.php file. With this in mind, I made all the code examples in this course generic, so you can copy them out of the text file and paste them into the theme to make them work. Just remember that if you create your own custom post types and custom taxonomies, you have to change the names in the code snippets for them to work.

Show transcript

This video is part of

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

40 video lessons · 28391 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
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Create an Online Portfolio with WordPress.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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.