I need to build a custom post type for the Toys I’m selling. The custom post type I want to create is “Toys”. I want them to have a categories/tags so I can sort them later, Tags I want to create for now is “Bath Toys”, “Magnets”, “Yoyos”, and “Glow in the Dark”.
I think if I can observe the code, I can try to analyze it and just replicate it later.
Here’s the tutorial that I’ve been trying to follow. But it still confuses me how to add taxonomies or tags.
I am adding this functions to the functions.php
of my child theme and I am using WordPress 3.3.1
You want to define your taxonomy and custom post type in your functions.php using the
register_taxonomy()
andregister_post_type()
functions.Here is an example what it could look like:
Then you need to go to the admin back-end and you should see Toys right below Post, create categories you desire in ‘Toys Categories’.
I know i am late but this might help those who are struggling to find an easy way to add WP Custom Post Types.
There is an awesome library to work with WordPress Post types and Taxonomies.
Take these steps this will make your life simpler.
in your themes directory run this command.
$ composer require azi/raskoh
include composer autoloader to your themes functions.php
require_once "vendor/autoloader.php";
after require add this code to register post type
`
the Raskoh (library) will take care of the rest.
here is the library on
Github