WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the following JQuery script from this answer to toggle the display of metaboxes dependant on the Page Template selected. The example below shows the featured image metabox when the default template is selected:

$(function() {

    $('#page_template').change(function() {
        $('#postimagediv').toggle($(this).val() == 'default');


My possibly simple question is... How do I get this code to only show the featured image box for my Page Template entitled: Services?

I have tried simply changing the 'default' to 'Services' but no luck.

share|improve this question
up vote 0 down vote accepted

The value is not the same thing that you see when you look at the toggle. That part is for humans. To see the value you have to look at the source of the page. If you have a template created by template.contact.php the value in that box would be template.contact.php, so it looks like the value is the php file name.

share|improve this answer
Thank you so much, I love you guys x lol – leannekera Sep 1 '13 at 19:31

The value of the select is setted to the file name so, assuming youf template file is services.php

jQuery().ready(function($) {

var $featImgDiv = $('#postimagediv');

$('#page_template').change(function() {
    if ( $(this).val() == 'services.php' ) {
    } else {

share|improve this answer
Sorry G. M I tried s_ha_dum's responce first and it worked, as far as I can see your responce is equally amazing however, if I could tick you both I would! – leannekera Sep 1 '13 at 19:32
When I aswered @s_ha_dum answer was not there (or I would not have answered), I think we answer at the same time (now I see answered 17 mins ago for both) – gmazzap Sep 1 '13 at 19:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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