Can't set page template for custom post type (page)? #111

Closed
Brenderous opened this Issue Feb 10, 2012 · 12 comments

Projects

None yet

8 participants

@Brenderous

Are we no longer able to set the Page Template for custom post types, even if their "Capability type" is set to "page"?

What's the deal?

@fabiodexter

same problem, here.

@imjp
imjp commented Mar 7, 2012

I'm wondering the same thing. I really need the page template..

@gabor-udvari
Member

Do you mean something like: single-customtype.php and archive-customtype.php templates in your theme? Those should work with the recent github version, I checked it.

@kobobo
kobobo commented Mar 7, 2012

Yes it works fine!

@gabor-udvari
Member

I was wrong, the bug is that if you edit a page, there's a box where you can select the template, but there's no such thing with a custom post type. I'll look into this.

@gabor-udvari
Member

This is a Wordpress limitation (bug). The function which displays the page attributes metabox checks the post_type, not the capability_type, see wp-admin/includes/meta-boxes.php line 583:

<?php
if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) {
                $template = !empty($post->page_template) ? $post->page_template : false;
                ?>
<p><strong><?php _e('Template') ?></strong></p>
<label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
<option value='default'><?php _e('Default Template'); ?></option>
<?php page_template_dropdown($template); ?>
</select>
<?php
        } ?>

It would be nice if this would be fixed in the Wordpress core, but it will be faster if we workaround this.

@gnuget
Member
gnuget commented Apr 10, 2012

I discussed with Edgar about this a few months ago and one option was giving back the "write panels engine" from MF1.

The write panels was the way to we simulate the "post types" when wordpress did not was ready for manage the post type for him self. So restoring the Write panels engine means: Adding code for do almost the same to the post types, this is not DRY and eventually will be more hard maintain the code.

For that we delayed the reimplementation of this feature until we figure out a better way to workaround this problem.

Would great to use this issue for discuss possible solutions for this problem, just taking in account to the write panels is not a option

@gnuget
Member
gnuget commented Jul 6, 2012

Btw i think to i know how workaround this

I'm going to do a couple test before make a push.

@gnuget gnuget added a commit that closed this issue Jul 7, 2012
@gnuget gnuget page template for content types close #111
Now the Custom post types created by magic fields have the hability to
choice a template (like the pages does) if has the "page attributes"
option checked.
d5e6b22
@gnuget gnuget closed this in d5e6b22 Jul 7, 2012
@gnuget
Member
gnuget commented Jul 7, 2012

Would be awesome if someone of you help us to test this. :-)

@elbego
elbego commented Sep 20, 2012

Hi - have installed and tested - once publish is clicked it reverts back to default template?

@inkbeard

Hey guys, I'm having the same problem. i have a put the code in the 3 files, but when I update or publish, the file automatically reverts back to the Default Template. Is there any additional steps I can try to help out? Thanks for all the hard work.

@gnuget
Member
gnuget commented Dec 7, 2012

no, there is not additional step.

Can you provide more info?

which wordpress version.
Browser.
There is another plugin active?

EDIT I just test it again and all seems to work fine, if this is not working for someone i will need more info, (the name of the post type, if has some custom fields etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment