Creating custom post type

Hi there
I’d like to create a custom post type for my site.
I already watched several tutorials and get to the wordpress help forum but x theme seems to be
organized differently.
Is there any tutorial here ? video ? to understand how this can be done ?
thanks

Hi There @vlad

Thanks for writing in! You can use a plugin like CPT UI (https://wordpress.org/plugins/custom-post-type-ui/) to create custom post types. You can check the following tutorial for more information (https://www.wpbeginner.com/wp-tutorials/how-to-create-custom-post-types-in-wordpress/).

If you also want to create a custom template, please refer to the following guide (https://theme.co/apex/forum/t/building-a-custom-template/30350/4?u=mldarshana).

Hope that helps.

thanks a lot …

You’re welcome!

Hi guys

I’ve just finished reading all the material and created my custom types.
All custom fields are added. All is ok inside my admin.
Unfortunately I feel the content you pointed out before is thought for pages not for post types.

My main concern is creating 1 custom type, each with 1 archive page with different designs.

Any information, video or article would be very welcome.
Many thanks

Ok I’ve just read this article : https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/#taxonomy-template-hierarchy

If I understand correctly I need to copy archive.php and modify the template and the name with my-custom-type.php.
Am I correct ?

Also, where to paste the modify file ? inside child theme ?

thanks

Hello There,

Because what you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

And yes you are correct. You will have to add the modified file in the child theme with the same folder location.
You might need to check out these thread for your referrence:

Hope this helps.

Thanks a lot for answering …

I already have installed child theme and made a lot of minor modifications there which work great.

The problem is template structure of x is a bit overwhelming at first glance and not very easy
to understand.

Just an idea … Am I correct if I try to create my own custom types based on “portfolio” type ?
I mean, do I have to copy all files and structure there to have my own types ?

What I want to accomplish is maybe a bit complex but nothing really fancy, just want to create
custom types adding specific custom fields.

I need to create 2 templates ; 1 for the post itself showing all custom fields and another one for each archive page
with a form for searching based on some criterias.

I’m really happy with x and pro but It would be a really good idea to create specific tutorials about that pdf, or video to avoid wasting your time and ours answering or asking same questions again and again.

I use another themes and they have really useful videos on youtube explaining that step by step.

Answers from the forum have not enough information because each one is asking for different customized project
and we always just have a “bit” of the information we need …

Many thanks

Hi @vlad,

Yes, you’ll have to copy them since you’ll have to customize them. Let’s say the structure is a group of templates, hence, you’ll need the group of templates for each post type you’ll create.

The standard is the same as Wordpress, it’s just in X theme, it’s separated into multiple parts and located mostly in framework/views/. It’s cleaner than having all the templates in the main theme’s folder.

But yes, you’ll have to use X theme’s function to call for each template parts which is x_get_view();, example

x_get_view( x_get_stack(), 'wp', 'index' );

This means get the template wp-index.php of the current stack, it will then load the file /x/framework/views/integrity/wp-index.php (Integrity as a sample stack).

And that’s it, there is no limitation of how you’ll chain-calling your templates. We only recommended copying the exact structure as a starting point, and as a reference. And noted about the tutorial and videos.

Thanks!

1 Like

Thanks a lot for replying.

I decided to copy portfolio type to make this easier to start before adding code to create customized templates.

So I copied files and renamed them using my custom type “entradas”.
I edited them replacing all instances I found inside from “portfolio” to “entradas”

These are all files I copied and edited from portfolio type. (all copied from portfolio type)

  • x-child/single-x-entradas.php
  • x-child/framework/views/global/_script-isotope-entradas.php
  • x-child/framework/views/global/_entradas.php
  • x-child/framework/views/integrity/wp-single-x-entradas.php
  • x-child/framework/views/integrity/template-layout-entradas.php
  • x-child/framework/views/integrity/template-layout-entradas.php
  • x-child/framework/views/integrity/content-entradas.php

Unfortunately it returns this message error on the front page Fatal error: Call to undefined function x_is_entradas_category()

Do you have an idea why this happens ? Did I miss any file ?

many thanks

Hello There,

That is because there is no function for that at the moment. So that it will be resolved, you will have something like this:

// Is Entradas Category
// =============================================================================

function x_is_entradas_category() {
  return is_tax( 'entrada-category' );
}

The code should work provided that you have registered entrada-category as the taxonomy of your custom post type.

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Hope this helps.

1 Like

thanks ruenel !
where do I have to paste this code ?
many thanks

Hi Vlad,

Add it on your child theme’s functions.php file.

Thanks,

:+1::+1::+1::+1::+1::+1::+1::+1: thanks I’m going to do this right now

You’re welcome! :slight_smile:

Hi there guys

I’m more than happy with my new template for my custom type single post wich I finally
make correctly adding several ACF fields.

Unfortunately I face another problem trying to create a customize index page for all my posts.
It seems I cannot modify the existing one without having all categories’ pages also modified.

Could you please let me know what are the files I need to use to do this ?
Any tutorial there ?

Many thanks

Hi There,

The category page is using the x/framework/views/global/_index.php file.

You need to copy this file to the child theme in the same directory.

For more information, please take a look at this:

Hope it helps :slight_smile:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.