Yes you’re not switching in and out of PHP correctly, try this…
<?php if (is_page('about') || (is_page('credits') || (is_page('links')) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/widesidebar.css" type="text/css" media="screen" />
<?php } elseif (is_page('contact') || (is_page('media-room') || (is-page('store') || (is-page('projects')) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/nosidebar.css" type="text/css" media="screen" />
<?php } else { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } ?>
Hi t310s_
I put in your code (straight copy and paste) and the same error message came back.
Is it possible that my host has an issue with {‘s?
I found this on my Host’s FAQ page. Does this effect template pages in WordPress?
PHP Errors: Why I get “.. unexpected T_STRING …” error?
You may get this error because all .html files are parsed as PHP here. So, if your .html file contains “<?” or “?>” tags/text (which shows for file parser that PHP code started), you get this error. This can happen with XML files if they are not using correct content type.
If order to fix this error you need to remove “<?” and “?>” symbols or entire tags with these symbols from your HTML page source.
a few times, you are using a hyphen – instead of the underline _ , for instance here:
(is-page('store')
Thanks alchymyth for catching that, but the error shows up well before I made those mistakes.
Must be something else going on….
Missed the typo’s, i just focussed on the PHP tags, oops.. anyway..
How about you just post the complete code from whichever file you’re doing this in…
The message above shouldn’t make any difference, we’re not dealing with HTML files (.htm, .html etc….)
PHP files will accept HTML providing the syntax is correct and tags are open and closed appropriately.
Please put the complete code in a pastebin and post the link back here.
http://wordpress.pastebin.com/
Update, noticed some more errors in the code, try this..
<?php if (is_page('about') || is_page('credits') || is_page('links')) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/widesidebar.css" type="text/css" media="screen" />
<?php } elseif (is_page('contact') || is_page('media-room') || is_page('store') || is-page('projects')) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/nosidebar.css" type="text/css" media="screen" />
<?php } else { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } ?>
Few too many (
@iridiax
Does the array option support multiple page checking?
The codex page doesn’t specifically say it does that’s why i’m asking.
me again; after playing with the code for a while, i realized that the opening brackets infront some of the ‘if’s are wrong:
<?php if (is_page('about') || is_page('credits') || is_page('links')) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/widesidebar.css" type="text/css" media="screen" />
<?php } elseif (is_page('contact') || is_page('media-room') || is-page('store') || is-page('projects')) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/nosidebar.css" type="text/css" media="screen" />
<?php } else { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } ?>
hope it works 😉
Does the array option support multiple page checking?
Yes, and this is what I always use for my multiple page conditions.
is_page(array(42,’about-me’,’About Me And Joe’)
Ah i see, the example just doesn’t make it obvious…
So a cleanup on before…
<?php if (is_page(array('about','credits','links'))) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/widesidebar.css" type="text/css" media="screen" />
<?php } elseif (is_page(array('contact','media-room','store','projects'))) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/nosidebar.css" type="text/css" media="screen" />
<?php } else { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } ?>
🙂