If you are not using WordPress Loop, you cannot use any wordpress method, so you should use pure php.
You can use this code. And they will definitely help you :)
$page_id = @$_GET['page_id']; if (!is_numeric($page_id)) { // Then the uri must be in friendly format aka /my_domain/category/onepage/ // Try this //$path = '/www/public_html/index.php/'; ///$path = '/my_domain/category/onepage/'; $path = $_SERVER['REQUEST_URI']; // Clean the uri //$path = str_replace('/', '', $page); $path = str_replace('.php', '', $path); //$path = str_replace('?s=', '', $path); $path = $path ? $path : 'default'; $path_len = strlen($path); $last_char = substr($path, $path_len -1); //echo $last_char; $has_slash = strpos($last_char, "/"); //echo $has_slash; if ($has_slash === 0) : $path = substr($path, 0, $path_len -1); elseif ($has_slash === null) : $path = substr($path, 0, $path_len); endif; //echo "path: ".$path; // '/www/public_html/index' $page = substr(strrchr($path, "/"), 1); echo "page: ".$page; // 'index' } $my_page_id = 31; $my_page = 'mypage'; //echo "page: ".$page; //echo "page_id ".$page_id; if($page_id == $my_page_id || $page == $my_page) { // your stuff.... }
Enjoy it!
edcv Feb 12 '14 at 9:13 2014-02-12 09:13
source share