Customizing sidebar
-
Hi,
I’ve check this codex article about sidebar customization but i’ve one question.I want to use some specific code (in the sidebar) for several specific pages (i.e. code x for pages 8,9,10; code y for pages 1,35), according to the article this should work:
<?php
// let's generate info appropriate to the page being displayed
if (is_home()) {
// we're on the home page, so let's show a list of all top-level categories
echo "HTML for home page";} elseif (is_category()) {
// we're looking at a single category view, so let's show _all_ the categories
get_calendar();
echo "HTMl for categories pages";} elseif (is_single()) {
// we're looking at a single page, so let's not show anything in the sidebar
get_calendar();
echo "HTML for single posts";} elseif (is_page()) {
// we're looking at a static page. Which one?
if (is_page('8')) {
// our about page.
echo "HTML for page 8";} else {
// catch-all for other pages
echo "<p>Vote for Pedro!</p>";
}
} else {
// catch-all for everything else (archives, searches, 404s, etc)
echo "<p>Pedro offers you his protection.</p>";
} // That's all, folks!
?>I wonder if it’s possible to assign differents values to that piece of the code above:
// we're looking at a static page. Which one?
if (is_page('8')) {
// our about page.
echo "HTML for page 8";in order to use the HTML not only in page #8 but also in #4, 5 etc..
I don’t know PHP so I don’t know if this is possible.
Thanks in advance.
- The topic ‘Customizing sidebar’ is closed to new replies.