Home Forums Themes Support How to create WordPress Custom Post type and display template

This topic contains 0 replies, has 1 voice, and was last updated by  admin 2 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1690

    Hi all our customer,

    In this tutorial we’ll help you create new custom post type in our theme and display it in new template.

    1. Create new Custom Post type

    • Step 1: go to path {yourwebroot}/wp-content/plugins/haru-xxx-core/includes/posttypes then create new posttype by duplicate testimonial.php file. You can change name to post type name you want to create. (Example: actor.php)

    More details to understand the code you can read here: https://codex.wordpress.org/Function_Reference/register_post_type

    • Step 2: Open file _init.php in this posttypes folder and add the code like this:

    You will have new Posttype named is Actor

    2. Display Custom Posttype

    You need to know about WordPress template structure from here: https://wphierarchy.com/

    2.1. Display Archive page:

    You can skip this step if use default template from archive for blog page.

    • Step 1: go to path {yourwebroot}/wp-content/theme/xxx/(XXX is our theme folder) and duplicate archive-haru_video.php and change haru_video to your posttype name (Example: archive-haru_actor.php). Also please change code in this file (archive-haru-video to archive-haru-actor)
    • Step 2: go to path {yourwebroot}/wp-content/theme/xxx/templates/ and duplicate archive-haru-video.php to archive-haru-actor.php

    (All variable in this template to set layout used in Theme Options so you can read file {yourwebroot}/wp-content/theme/xxx/framework/includes/theme-options.php

    • Step 3: {yourwebroot}/wp-content/theme/xxx/templates/archive/ then duplicate content-haru-video.php to content-haru-actor.php to display your content.

    2.2. Display Single page:

    • Step 1: go to path {yourwebroot}/wp-content/theme/xxx/(XXX is our theme folder) and duplicate single-haru_video.php and change haru_video to your posttype name (Example: single-haru_actor.php). Also please change code in this file (single-haru-video to single-haru-actor)
    • Step 2: go to path {yourwebroot}/wp-content/theme/xxx/templates/ and duplicate single-haru-video.php to single-haru-actor.php
    • Step 3: {yourwebroot}/wp-content/theme/xxx/templates/single/ then duplicate content-haru-video.php to content-haru-actor.php to display your content.

    Above is step to step to create new custom posttype and display them in our theme. More details you need is read and understand about the code.

    Reference topic to help you add custom meta to posttype in our theme: http://harutheme.com/forums/topic/add-new-metabox-circle-single-video-film-actor-director/

    Hope this help you all to customize theme to fit your work!

     

    ******

    Best regards,

    HaruTheme

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.