/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Parse error: unexpected ‘<‘

I’m a frontend guy so customizing a wordpress template usually goes as far as some css and html markup. In this case though, I want the homepage to load a different style sheet than the others. PHP to the rescue right? ERR WRONG.

Could somebody show me how much I fail at php and why? =D

[CODE]<?php if (is_home() ) { ?>
<?php echo ‘<link rel=”stylesheet” href=”‘ ?> <?php bloginfo(‘stylesheet_directory’); ?> <?php echo ‘/style-Black-home.css” type=”text/css” media=”screen” />’; ?>
<?php } else { <?php echo ‘<link rel=”stylesheet” href=”‘ ?> <?php bloginfo(‘stylesheet_directory’); ?> <?php echo ‘/style-Black.css” type=”text/css” media=”screen” />’; ?>
} ?>[/CODE]

[CODE]Parse error: syntax error, unexpected ‘<‘ on line [3][/CODE]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@JunkMaleOct 14.2009 — You do not need that many tags, is this the sort of thing your looking at
[code=php]<?php
if (is_home() ) {
echo '<link rel="stylesheet" href="' .bloginfo('stylesheet_directory') . '/style-Black-home.css" type="text/css" media="screen" />';
} else {
echo '<link rel="stylesheet" href="'.bloginfo('stylesheet_directory') . '/style-Black.css" type="text/css" media="screen" />';
}
?>
[/code]


Or you could
[code=php]<?php
$css_root = bloginfo('stylesheet_directory');
echo "<link rel='stylesheet' href='{$css_root}/style-Black";
if (is_home() ) {
echo "-home";
}
echo ".css' type='text/css' media='screen' />";
?>
[/code]
Copy linkTweet thisAlerts:
@SpectrumFireauthorOct 15.2009 — Hmm that didn't do the trick.

It's spitting this back now:

[CODE]http://76.12.88.190/cards/wp-content/themes/cards4everyone<link rel='stylesheet' href='/style-Black-home.css' type='text/css' media='screen' />
[/CODE]


I don't get it ?
Copy linkTweet thisAlerts:
@NogDogOct 15.2009 — Looks like the bloginfo() function is doing the echoing itself, as opposed to returning a string. If so, you might have to break this up into multiple commands (or change the bloginfo() function).
[code=php]
<?php
if (is_home() ) {
echo '<link rel="stylesheet" href="';
bloginfo('stylesheet_directory');
echo '/style-Black-home.css" type="text/css" media="screen" />';
} else {
echo '<link rel="stylesheet" href="';
bloginfo('stylesheet_directory');
echo '/style-Black.css" type="text/css" media="screen" />';
}
?>
[/code]
Copy linkTweet thisAlerts:
@SpectrumFireauthorOct 15.2009 — That did it, thanks a mil!
×

Success!

Help @SpectrumFire spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...