WordPress.org

Ready to get started?Download WordPress

Forums

content template (post format) for custom post type (3 posts)

  1. Koff
    Member
    Posted 2 years ago #

    Hi,

    I want to add custom post type for the blog page.
    But I want this posts to use there own template.

    I though that the easy way is to add "content-my_post_type.php" to my theme.
    But of course it dosen't work.

    Any idea how to hack this?

  2. LaBOdeMarie
    Member
    Posted 2 years ago #

    Hello,
    Did you find an answer ?
    If yes, I'm interested.
    Thank you

  3. Koff
    Member
    Posted 2 years ago #

    Hej

    Yes I did.

    I added file with the name content-.php

    with the following code:

    $templates = array();
    $templates[] = "content-{$post->post_type}.php";
    $templates[] = "content.php";
    locate_template($templates, true, false);

    and then content-posttype.php works!!!!!

    Let me know if it works for you,as this is untested live yet.

    Koff

Topic Closed

This topic has been closed to new replies.

About this Topic