i'm trying to change a custom query based on the page title, so I'm using wp_title('',false); to put into a variable, then use a switch statement to do different things.
Using this code:
$my_page_name = wp_title('',false);
echo 'page name: '.$my_page_name.'<br />';
switch ($my_page_name){
case "Activities and Family Fun":
$cat_slug = "activites-and-family-fun";
break;
case "Automotive":
$cat_slug = "automotive";
break;
case "Dry Cleaning":
$cat_slug = "dry-cleaning";
break;
default:
echo "no cat_slug value found, but the page name was ".$my_page_name."<br />";
i actually have like 10 more cases in that statement but that's irrelevant. $my_page_name echoes as "Automotive" so the $cat_slug should be set to "automotive", but instead it goes to the default where $my_page_name is still "Automotive."
That seems completely wrong, but here's what's the crazy part: if I add this code before my switch statement
if($my_page_name = "Automotive")
echo 'himom';
else
echo 'everything is insane';
then it echoes "himom" and my switch statement work correctly, $cat_slug gets set to "automotive".
But why!?
Is there something about switch statements that I don't know about or is it something in the wp_title call that's buggy, or something else? My variable has the right information, but my switch statement can't tell unless I run an if statement with that variable first, and that doesn't make any sense at all to me.
Thanks for any help.