WordPress-Add new Custom Post section

Hello Friends !!

Today, wordpress is widely used opensource. And in wordpress 3.0 and later versions, there are many new features which are not in later versions.

Yes, today I will share with you one new feature .  Do you know How you can add new custom post section in wordpress ?

Understand what I mean ? Ok, dont take tension. I will show you want I mean and what i want to share with you. Please see image :

See above image. In this, I have added two new section Deals and Podcast. I am going to share with you that how can you make this ?

First of all, open post.php file which it located in wp-include folder.

After that find function create_initial_post_types() and place below code in this function :

register_post_type(‘podcast’, array(
‘label’ => __(‘Podcast’),
‘singular_label’ => __(‘Podcast’),
‘public’ => true,
‘show_ui’ => true,
‘capability_type’ => ‘post’,
‘hierarchical’ => false,
‘rewrite’ => false,
‘query_var’ => false,
‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’, ‘excerpt’, ‘custom-fields’ )

more details, click below :

Above code registers new custom post type podcast in your admin. You can see it in your admin. For insert posts in this section, place below code after completion function create_initial_post_types().

add_action(“manage_posts_custom_column”, “my_custom_columns”);
add_filter(“manage_edit-podcast_columns”, “my_podcast_columns”);

function my_podcast_columns($columns)
$columns = array(
“cb” => “<input type=\”checkbox\” />”,
“title” => “Podcast Title”,
“description” => “Description”,
“length” => “Length”,
“speakers” => “Speakers”,
“comments” => ‘Comments’
return $columns;

function my_custom_columns($column)
global $post;
if (“ID” == $column) echo $post->ID;
elseif (“description” == $column) echo $post->post_content;
elseif (“length” == $column) echo “63:50”;
elseif (“speakers” == $column) echo “admin”;

Now you can add posts in this new section. Enjoy this new magic. But one question will be in your mind that how can i display these posts in front end ? Am I right ? Don’t worry. I also give you the code by which you can list these posts in front end. Just copy paste below code where you want to display losts in front end:

<?php $loop = new WP_Query( array( ‘post_type’ => ‘podcast’, ‘posts_per_page’ => 10 ) );
while ( $loop->have_posts() ) : $loop->the_post();


endwhile; ?>

Thats it !! If you like this post or if you have any query in wordpress on in PHP, feel free to comment me or contact me.

Thanks !!

  • Rs111222

    Where I have to add the last code WP_Query?

    And also I want to ask how to show posts from new section on some page, not on main blog page, but another custom page. Thx very much, sry for english 🙂

  • Anonymous

    First Thanks for your comment.
    The last code WP_Query is used to show the posts of the new custom post section. You can use this code in any custom pages. Using this code, the posts of the new custom post section will be displayed on that page.

  • http://my-addr.com/ Appoidoraiday

    waiting for next post

  • http://member.my-addr.com Appoidoraiday

    what I was looking for, thanks

  • http://www.facebook.com/judd.dunagan Judd Dunagan

    Awesome Post! Can 

  • http://www.facebook.com/judd.dunagan Judd Dunagan

    Sorry hit go to fast. Can you give feedback on the following. I would like to have single post page which will display lets say a portfolio item which I would only allow that post id and not all the posts in this new section.

  • asu

    can we do the same to create a custom page at admin section ?