Create a word press page map for a custom post type.

You can reuse the same idea as used here (how WordPress creates custom query pages), so creating pages for custom post types is not a difficult task. You must query the custom post type, and then display the query posts in the post type or multiple post types. This post will show you how to create a word press page map for a custom post type. Paging is similar to this numeric paging. Create a custom query to get all custom post types, and then display custom post types and loops and number pagination.
The first step in creating a custom post type is to create a custom post type using the following code:\/**
*Custom post type – register_post_type ()
*@Description njengah tutorial custom post type example
*@Link- https:\/\/gist.github.com\/Njengah\/839466b773085ac2430772e081357cee
*
*\/
Add_action (\
Function njengah_tutorial_cpt (){
$labels = array(
\
\
\
\
\
\
\
\
\
\
\
\
\
\
);
$args = array(
\
‘labels’ => $labels,
\
\
\
\
\
\
\
\
\
\
“capability_type”=>“page”,
\
\
\
‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘comments’, ‘revisions’, ‘page-attributes’, ‘custom-fields’ )
);
Register_post_type (\
}Function. After adding to the PHP file, you will see that the WordPress dashboard displays the custom post type \
Male: this code conforms to the specific custom post type
$paged > $range+1 && $showitems « First\
If ($paged > 1 & $showitems androg & lsaquo; Li Qian androg);
($i=1; $i <?php
/**
* 템플릿 이름: 튜토리얼 템플릿
*/

get_header();
이제 아래와 같이 페이지 속성 템플릿 옵션에 사용자 정의 페이지 템플릿이 표시됩니다. = $paged+$range+1 || $i \
}
}
if ($paged

i class=’flaticon flaticon-back’>

\
if ($paged

    <a href="\
    echo \
    }
    }Now that the user-defined post type paging function calling the user-defined post type paging function has been created in the page template, and the cycle has been run to display the user-defined post type, the paging function should be added at the bottom of the user-defined page template to display the page.
    The following code should be used to verify whether there is paging function after user definition. If it exists, it must be called to display pagination\/\/ Step 3: call paging function here.
    if (function_exists(\
    cpt_pagination($customPostQuery->max_num_pages);
    }We created a custom post type and a custom page template, added a custom post type pagination function, and displayed the custom post type and custom post type pagination function with query.
    You must add a style to the custom post type page map using the following code:\/**
    *Custom post type paging style
    *@By Joe Njenga
    *\/
    Pagination{
    Erase: both;
    Position: relative;
    Font size: 16px;
    Line height: 13px;
    Floating: right side;
    List style type: none;
    Width: 100%
    }
    . paging range,. Pagination a{
    Display: blocks;
    towards the left
    Margin: 2px 2px 2px 0;
    Down jacket: 6px9px 5px9px;
    Text decoration: none;
    Width: automatic;
    Color: #fff;
    Background: #237697;
    }
    A: hover paging{
    Color: #fff;
    Background: #000;
    }
    . pagination. Current{
    Down jacket: 6px9px 5px9px;
    Background: #999;
    Color: #fff; You are ready to see the results of this code. To view the custom post type page mapping, you must create a new page using the custom page template you created in step 2.
    After creating this page, the user-defined post type of query and the generated page tag must be displayed on the page, as shown below. If you want to create a custom post type page map for the last idea, you can add a custom query to get all the custom posts to be created and displayed, and use functions. You must call the custom paging function added to PHP. To get the complete code, you have added it to git repo and can access it from there. WordPress Custom Post Type Pagination.

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *