GJ Blog

Some web development stuff and Wordpress

Creating custom post types in WordPress is a great way to add new content types to your website. In WordPress you generally have only posts or pages. We can extend this with CPT (Custom Post Types). So to have a unique new group of articles with custom fields and taxonomies.

In WordPress these groups of articles are displayed on the Archive page as a list and have a single page for each post. As an example posts are displayed on archive.php and have single.php.

Lets say I have a my Web Design studio website and I want to make a section with all of the employees. With a personal page for each one and and archive page where everyone is listed.

In this tutorial we will do a CPT for the employees and two Elementor templates. One to display the Archive and another to display the Personal page

In the WordPress Dashboard lets navigate to the plugins and search for “Custom Post Type UI” and Install it and Activate it.

On the left menu we will have a new CPT UI Voice. We click on it and then on “Add/Edit Post Types”.

We write the names for the new cpt and “Add Post Type”. We will now have on the left menu the new CPT that we added.

Before building our Archive page with “Elementor Theme Builder” Lets change a few options on our CPT.

Lets go to CPT UI, in edit post types Select Employees if it’s not selected. Scroll down to settings, find “Has Archive” and set it to True(This makes it appear in the Theme builder conditions). Scroll down to the end, add Taxonomies by checking Categories or Tags if you want them, click on Save Post Type.

In “Templates” click on “Theme Builder”. We now have, on the left “Single Page” and “Archive”. Lets make the Archive first.

Click on the “+” sign or add new. An Elementor page will open with a Library popup. We now insert a pre made block.

Click on Publish and set Add Condition. Choose the name of the CPT created and Save.

Now that we have our archive page to see it and add it to the menu we need to add some posts to the CPT. We do it in the same way as Posts. In my case under Employees -> Add New I will add some “employees posts”.

Lets add the archive page to the menu. In Appearance -> Menus, under Add menu Item lets choose our CPT -> View All -> All Employees and “Add to Menu”

We now have or Archive Page and a Link in the Menu

Now to add the single page, which is the one that appears when you click on the read more, we do the same as before. Lets navigate to Templates -> Theme Builder. Click on the “+” sign near Single Page and insert one default block.

Click on Publish. In the Conditions lets put Employees All. Save & Close. Now we also have our single page