Change Wordpress Admin Template Drop-down to a radio

201 Views Asked by At

What I am trying to do is change the admin template drop down to a radio button with the name of the template and a icon of what the template will look like. The problem is that is that when I select a template is does not save as that template.

Here is what I have so far.

    <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>-->


<form name="page_template" id="page_template">
    <span style="display:block; height:35px; clear:both;">
        <input type="radio" value='default'>
            <img style="top:6px;position:relative;padding-right:5px;" src="<?php bloginfo('template_url'); ?>/page-icons/gallery-icon.jpg" /><?php _e('Default Template'); ?>
    </span>
    <span style="display:block; height:35px; clear:both;">
        <input type="radio" value='gallery'>
            <img style="top:6px;position:relative;padding-right:5px;" src="<?php bloginfo('template_url'); ?>/page-icons/gallery-icon.jpg" /><?php _e('Main Gallery'); ?>
    </span>
</form>

I am editing the meta-box.php in the wp-admin > includes folder. Any Help would be great.

1

There are 1 best solutions below

0
On

I was going to reply to your latest comment, because I can't test this right now. I think either I misunderstand you or you misunderstand me.

I would expect the behaviour you're seeing (the default template to be selected) if nothing is passed, which I think is what would be happening with your current code.

Try replacing everything - including your <form> tags - with:

    <span style="display:block; height:35px; clear:both;">
        <input type="radio" name="page_template" value='default'>
            <img style="top:6px;position:relative;padding-right:5px;" src="<?php bloginfo('template_url'); ?>/page-icons/gallery-icon.jpg" /><?php _e('Default Template'); ?>
    </span>
    <span style="display:block; height:35px; clear:both;">
        <input type="radio" name="page_template" value='gallery'>
            <img style="top:6px;position:relative;padding-right:5px;" src="<?php bloginfo('template_url'); ?>/page-icons/gallery-icon.jpg" /><?php _e('Main Gallery'); ?>
    </span>

That's what I meant in my first comment - move the name="page_template" attribute onto your input tags. I don't think you need to introduce a new <form> where there wasn't one before.