Template page attribute not showing on my new page-capable Custom Type #1051

Closed
dgilperez opened this Issue Feb 10, 2013 · 9 comments

Projects

None yet

4 participants

@dgilperez

Hi!

I'm trying to get Page Attributes that are default on Page type, on my new fancy Pods Custom Type. I'm creating this Sample custom type and giving it capability type to Page and enabling page attributes.

In the editing interface of my new Sample, the Page attributes section will only show the Order option, but not the Template option.

Is there any way to get this feature on my Sample pod?

Thanks for the great work !!!

@sc0ttkclark sc0ttkclark was assigned Feb 10, 2013
@sc0ttkclark
Member

Pods doesn't do anything special here, WordPress itself currently hardcodes the check for the page template selector to only be available for the 'page' post type. I'll add this to the list of feature requests to see if we can optionally circumvent the metabox and show it anyway.

@dgilperez

@sc0ttkclark thanks for the quick response! If I understand correctly, WordPress itself could be patched to check for this condition removing the hardcoding ... at the risk of asking too much of your time, could you point me to the file / line where this hardcoding takes place, and some hint on how to fix it?

Many thanks again!!!

@sc0ttkclark
Member

wp-includes/meta-boxes.php around line 641:

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
    } ?>
@dgilperez

Thanks !!

For those interested, I'll be going for the moment with this not very clean workaround:

if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) {
        $template = !empty($post->page_template) ? $post->page_template : false;
        ?>

Becomes

if ( 'post' != $post->post_type && 0 != count( get_page_templates() ) ) {
        $template = !empty($post->page_template) ? $post->page_template : false;
        ?>

@Bobcatou
Bobcatou commented Mar 5, 2013

I specifically need this. I hope this request is incorporated into Pods very soon. Thank you.

@adamthwaite

this is a deal breaker for me. not an advanced developer so i can't contribute unfortunately, but this is killer... :(

@sc0ttkclark
Member

Sorry, it's a deal breaker for a lot of us. I hope we can get this fixed in WordPress core very soon. I'm currently thinking about alternative ways that Pods could add this feature for Custom Post Types.

@adamthwaite

Are you a Pods developer? If so, wow! :) Awesome stuff.

So, is it correct that the fact that my custom type is page, not post, it's only ever going to render using index.php, and it won't help to make a page template called entity-name.php?

I'm actually using pages for something separate (umm, like pages, wink) so the above hack wouldn't work.

If this gets pulled off, WordPress becomes essentially limitless...

@sc0ttkclark
Member

Yes, I'm the lead dev of the Pods project :) and thanks!

The custom type does not matter for the page template selection, that is hardcoded for the 'page' post type only. But for the template hierarchy, it should work no matter what. Just remember that your entity name is using underscores.

Here's more information about how template hierarchy works and how you can take advantage of it in your theming:

http://codex.wordpress.org/Template_Hierarchy

Template Hierarchy chart for WordPress

@dgilperez dgilperez closed this Oct 2, 2015
@sc0ttkclark sc0ttkclark self-assigned this Dec 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment