If page, get blogroll category

Hi I’m trying to figure out how to say:
if This page, then use this blogroll category. I have
wp_list_bookmarks (‘category’)

but I don’t know the actual php syntax. Also, I place this on the template related to my pages, but if a different page shows does that also need to be in the string? I have 6 pages in all, with six categories (one to one) I want to assign.
Thanks for any help.

Hi Joan ;D

Here is a quick script i’ve put together for you,
$page = str_replace(’/’, ‘’, $_SERVER[‘SCRIPT_NAME’]); // get the page name and chop off slash
$pages = array(‘index.php’, ‘home.php’, ‘about.php’); // create an array of pages

// check the page is the pages array
if(in_array($page, $pages))
// use a switch to find out which page we are on
case ($pages[0]) : // first value in $pages array
echo ‘Your on the index page’;
case ($pages[1]) : // second value in $pages array
echo ‘Your on the home page’;
case ($pages[2]) : // third value in $pages array
echo ‘Your on the about page’;
default : // something weird happened!
echo “I don’t know of this page?!”;
else // the page is not in the array
echo ‘Unknown page!’;

To use it for yourself, change the pages array to your pages and also my echo statements to do whatever you wish for the page selected,
i hope this helps

Sponsor our Newsletter | Privacy Policy | Terms of Service