• Resolved egorpromo

    (@egorpromo)


    I have wordpress 3.1.
    In theme’s functions.php I write in simple code:

    add_action( 'init', 'create_zombie_post_type' );
    function create_zombie_post_type() {
    	register_post_type('zombies',
    		array(
    			'label' => 'Zombies studio',
    			'public' => TRUE,
    		)
    	);
    }

    Then I create single.php file in theme directory with simple content inside to check the page will be viewed:

    You are reading single post

    Then I write new post in my zombies post type and try to read it. But I can’t see my content. I can see only my content if I write standart wordpress post but not zombies. Also I can’t use single-zombies.php file too. If I make use twentyten theme of wordpress and want to add my zombies post type I get the same incorrect results.

    What I do in wrong way? Codex points that it is possible.

Viewing 4 replies - 1 through 4 (of 4 total)
  • When you say you can’t see your content, you mean in the list of posts?

    The default loop will not return custom post types; you’ll need to adjust the loop query to add them. This link should get you started.

    Thread Starter egorpromo

    (@egorpromo)

    Thanks for reply. Your note is very important for me now but not resolves my problem.
    When I said I can’t see content, I mean any content in single.php and single-zombies.php files. That content could be the list of posts or HTML-tags or simple text. I just cant’t open that theme template files anyway. In my case I write in the single.php and single-zombies.php the simple phrases “You are reading single post” and I want to see it without any another content when I am in the page with my single custom post “zombie”.

    Description what I try make is here

    Have you done the permalink thing? When a new custom post type has been defined, you need to go to Settings > Permalinks and just click Save Changes (you don’t even have to change anything). I’m not sure what it does, but its necessary to view the post.

    I often forget to do this. As a matter of fact, I forgot to do it while testing this for you ??

    I can copy-paste your above code and it works for me (with single-zombies.php).

    Thread Starter egorpromo

    (@egorpromo)

    Thanks! Your comment is right.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to use single.php file with custom post types’ is closed to new replies.