How to display custom post type on wordpress page

How to display custom post type on wordpress page

From wordpress 3.0 version we got the custom_post_type method introduced in wordpress api.  Here we shown, How to display custom post type on wordpress page If you want to know how use this method or create the custom post type then use following URL:

How to display custom post type on wordpress page

https://purabtech.in/how-to-use-the-custom-post-type-in-wordpress-3-0/

In this tutorial I will show how to show the custom post type in wordpress theme page. First create custom-post.php page in your wordpress theme folder and use following code.

[/php]

php

/*Template Name: custom post*/

?>

php get_header(); ?>

<div id=”container”>

<div id=”content” role=”main”>

php the_ID(); ?>”

php $recent = new WP_Query(‘post_type=custom_post′); while($recent->have_posts()) : $recent->the_post();?>

php the_title( ‘

‘, ‘

‘ ); ?>

<div>

php the_content(); ?>

php

the_content();
global $post;
$custom = get_post_custom($post->ID);
echo $custom_meta = $custom[“custom_meta”][0];

?>

php wp_link_pages( array( ‘before’ => ‘

‘ . __( ‘Pages:’, ‘wordpressapi’ ), ‘after’ => ‘

‘ ) ); ?>

php edit_post_link( __( ‘Edit’, ‘wordpressapi’ ), ”, ” ); ?>

</div><!– .entry-content –>

php comments_template( “, true ); ?>

php endwhile; ?>

</div><!– #content –>

</div><!– #container –>

php get_sidebar(); ?>

php get_footer(); ?>

[/php]

Then go to your wordpress admin panel and create page called custom page and from right side panel you will find the page attribute section use the template drop down and choose the custom post option.

How to display custom post type on wordpress page
How to display custom post type on wordpress page

Now you are set for showing your custom post type in custom page. Open your custom page on that page you will see all the entries of custom post type.

For more detail information about custom post type and using this check above URL.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

2 thoughts on “How to display custom post type on wordpress page”

Leave a Reply

Your email address will not be published.