Not getting posts of custom post types


I have created a custom template and trying to get a custom post of type "song", But it is displaying only the header and footer on the page. There is no post content coming. Even if I try to call general posts then also no content coming, Should I register this template anywhere in the theme? OR need to call anything here?

My code :

/* Template Name: song Page
 * Selectable from a dropdown menu on the edit page screen.

get_header(); ?>


if ( have_posts() ) {
   while ( have_posts() ) {
      query_posts( 'post_type=song'); 
   } // end while
} // end if

<?php get_footer(); ?>

Please help to correct my code. I want to display all posts of custom post type "songs".
I have already created a custom post type.

I am putting the above code in WordPress editor, I have installed a plugin called "PHP execution" so it executes PHP code.

rahul bhatt 2 months 0 Answers 8 views 0

Leave an answer