From the course: WordPress: Custom Post Types and Taxonomies
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Adding a custom taxonomy to a template - WordPress Tutorial
From the course: WordPress: Custom Post Types and Taxonomies
Adding a custom taxonomy to a template
- [Instructor] One of the nice things that we can add to our new post templates is the custom taxonomy we created. Since this taxonomy is not built into Wordpress core, we need to explicitly add the terms to our template. Luckily, Wordpress has a function that can help us out here, and it's called get the terms list. This function accepts a post ID, a taxonomy slug, what should go before the taxonomy list, how the list should be separated, and what comes after the taxonomy list. So we're going to want to add this nice comma-separated list of sizes to both our single and archive template. And let's start with the archive. First I'm going to copy this function here, so we can easily paste it later, and then in our code editor, I'm going to open the content excerpt business file. I'm going to scroll down to the 2019 entry footer, and right after the opening div, I'm going to add some markup. So I'm going to put this in a paragraph with the class "taxonomy-sizes". And then I'm going to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
The WordPress template hierarchy4m 9s
-
(Locked)
Setting up your child theme5m 47s
-
(Locked)
Creating a single custom post template3m 14s
-
(Locked)
Modifying the single template header4m 1s
-
(Locked)
Creating a custom post archive template3m 56s
-
(Locked)
Adding a custom taxonomy to a template4m 1s
-
(Locked)
Creating a custom taxonomy template2m 35s
-
(Locked)
-
-
-