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

Adding a custom taxonomy to a template - WordPress Tutorial

From the course: WordPress: Custom Post Types and Taxonomies

Start my 1-month free trial

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…

Contents