Is $emr_options a global variable or defined somewhere else? If not then that’s the problem, at that point $emr_options doesn’t equal anything.
The first thing I do when testing variables is to check if it even has anything. You can do this by adding the following line just above the if statement:
echo '<pre>', print_r($emr_options), '</pre>';
If you don’t see anything then the variable is not set. Otherwise you’ll see a list of values contained in $emr_options, including ‘pagetitle_url’ if it’s there.
Can you try: is_page(get_option('pagetitle_url')) instead?
Thread Starter
js2484
(@uniquelylost)
Thanks for the help @oz
Okay so I can get the first pagetitle_url to work but if I try to add additional ones like pagetitle_url22 they don’t work… I can confirm that the values are getting saved in the db… here’s an example of my code-
function emr_single_page_only(){
global $emr_options;
if (is_page(get_option('pagetitle_url'))) {
emr_mobile_redirect();
}
elseif (is_page(get_option('pagetitle_url22'))) {
emr_mobile_redirect2();
}
}
add_action('get_header','emr_single_page_only');
function emr_mobile_redirect(){
global $emr_options;
if ($emr_options['enabled'] == true)
{
$detect = new Mobile_Detect();
if ($detect->isTablet() && $emr_options['tablet'] == true)
{
$detect = "false";
}
elseif ($detect->isMobile())
{
header('Location: ' . $emr_options['mobile_url']);
exit;
}
}
}
Again, thanks in advance for any suggestions.
Thread Starter
js2484
(@uniquelylost)
After much trial and error I wonder is it even possible to use multiple is_page in this manner? If so it seems my logic is off for the ‘function emr_single_page_only()’.
is_page() can be called as often as needed, that’s not the problem. Unfortunately, I’ve no idea what the problem may be, everything seems in order.