0

I have a custom post type called agenda with a custom post template called single-agenda.php.

When I have a draft of an agenda post, this uses the content in the template single.php. When I publish it's ok, it uses the content in single-agenda.php.

I would like to see my draft content in single-agenda.php, how can I do that?

1

In some cases, the permalink structure must be updated in order for the new template files to be accessed when viewing posts of a custom post type. To do this, go to Administration Panels > Settings > Permalinks, change the permalink structure to a different structure, save the changes, and change it back to the desired structure.

from http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates

  • I've already tried, but nothing has changed. Thanks – user1514385 Sep 24 '13 at 13:00
0

Could this be a bug in WP?

Well not testet, but it should be something like this.

function wpse_115432_template_redirect() {
    global $post;

    if ( 'agenda' != $post->post_type && 'draft' != $post->post_status )
        return;

    $template_path = TEMPLATEPATH . '/' . "single-agenda.php";

    if ( !file_exists( $template_path ) )
        return;

    include($template_path);
}
add_action('template_redirect', 'wpse_115432_template_redirect');
  • Hello Horttcore, Thanks for your answer. I've pasted this function in my function.php but nothing change, with old and new draft created. – user1514385 Sep 24 '13 at 12:58
  • Do you have any idea ? – user1514385 Sep 26 '13 at 15:53
  • I've tried it with 'page' post type so it should defiantly work. – Horttcore Sep 27 '13 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.