• I wanted to use the dropdown theme switcher and it works fine – as long as I also keep the list of themes there too.

    If I remove the <?php if (function_exists('wp_theme_switcher')) { ?>
    <div class="sidebox">
    <div class="boxhead">
    <li><h3><?php _e('Themes'); ?></h3></div>
    <div class="boxbody">
    <?php wp_theme_switcher(); ?>
    </div>
    </li>
    </div>

    All of a sudden nothing shows up at all, not the sidebar, or the content, just the header.

    I don’t want both of these in the sidebar, just the dropdown one.

    Any reason why I can’t delete the above code and keep just
    ‘<?php if (function_exists(‘wp_theme_switcher’)) { ?>
    <div class=”sidebox”><div class=”boxhead”><h3><?php _e(‘Themes’); ?></h3></div>
    <div class=”boxbody”><?php wp_theme_switcher(‘dropdown’); ?></div>’

    Any help?

    Oh, and since I’m here, can anyone tell me what the ‘<?php } ?>’ code is? There are two of them in the bottom of my sidebar page.

Viewing 10 replies - 1 through 10 (of 10 total)
  • <?php } ?> is closing off a particular PHP statement in the template. For example, there should be one just after the code block you deleted, and would act as a closing tag for

    <?php if (function_exists('wp_theme_switcher')) { ?>

    Note the { at the end of that line. The } designates the end of the statement, and would need to be removed with it. And yes, leaving it in place could cause errors and weird display problems along the lines you’re describing.

    Thread Starter torontobroad

    (@torontobroad)

    Thanks, Kafka, but I have removed all of the code above, and tried to leave in just the code (almost the same) with the dropdown themes only, and then nothing shows up.

    Is there something I’m supposed to leave in?

    How come nothing shows up if I only put in the ‘<?php if (function_exists(‘wp_theme_switcher’)) { ?>
    <div class=”sidebox”><div class=”boxhead”><h3><?php _e(‘Themes’); ?></h3></div>
    <div class=”boxbody”><?php wp_theme_switcher(‘dropdown’); ?></div>’ code? Having that code only, makes everything disappear unless I’ve got both the regular theme list and the dropdown list?

    Little hard to troubleshoot an errorless PHP error, so view the source of your page through your browser and see if one is appearing there.

    Thread Starter torontobroad

    (@torontobroad)

    This is really maddening. I don’t see any mistakes when I view the source, and of course the page validates.

    But what could cause the page to disappear as soon as I remove the code for the theme switcher?

    I can move it up to the top of my sidebar and it works, and the dropdown switcher also shows up.

    But as soon as I take out the original list, without removing any extranneous code, nothing shows.

    Perform the edit as you describe, then copy the source of the template here:

    https://pastebin.com/

    and reply back with the url to your paste up. Then we can give it a test drive.

    Thread Starter torontobroad

    (@torontobroad)

    ok, I posted the code there, after taking out the regular theme code and leaving in the dropdown theme code.

    I logged it as name: torontobroad, and you can see it not showing up at https://www.torontobroad.com/blog.

    That’s a neat little function.

    Thread Starter torontobroad

    (@torontobroad)

    Sorry, I’ve revised that – so the post without the regular theme code in it, and only the dropdown code in it, is now at
    https://www.torontoblog.com/blog/indextest.php and if you go to https://www.torontoblog.com/blog you can see that it works as long as the two codes for themes are in it.

    Crap, that’s not working for indextest now either, it’s telling me, ‘Parse error: parse error, unexpected ‘}’ in /mnt/web_m/d46/s20/b024d5f9/www/blog/indextest.php on line 66′ but there’s no ‘ on line 66.

    Thread Starter torontobroad

    (@torontobroad)

    Sorry, I forgot to mention that this was with the “travelogue” theme.

    The parse error mentioned above would be due to the closing }, if it doesn’t have an opening one attached to a PHP statement of some sort.

    I only have the url for your first pastebin (you have to copy the url to it here, as the recent posts list over there tends to run off quickly), and from that I can’t tell why you would have two <?php } ?> near the end of the template. The first is most definitely connected to the if(function_exists()) statement, but there’s nothing else in the template that requires it (it could of course be runover from something in another included theme template, but I’m unable to see that).

    Anyway, here’s my edit to the original sidebar you placed in the pastebin site, sans the ThemeSwitcher code:

    https://pastebin.com/290470

    I also took out the second PHP tag with the closing }, so it may, or may not, break something.

    Thread Starter torontobroad

    (@torontobroad)

    Kafka, that worked, and then I just pasted the dropdown theme list in it and it seemed to work fine.

    I don’t know what you took out to make it show up, but thanks very much for whatever you did ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘I can’t remove the theme code’ is closed to new replies.