Research and Development work on PHP, MYSQ,JQuery,Angular Js,React Native,Laravel,Wordpress,Magento,Joomla
Showing posts with label Wordpress Hint. Show all posts
Showing posts with label Wordpress Hint. Show all posts
Friday, November 15, 2013
Friday, April 19, 2013
Get the post / page ID in functions.php
Usually the global variable $post will give the user all the information of the current post / page. This global variable is not available in functions.php (if the code is not in a function) so you can use the following code snippet to get the ID of the post/page ID based on current URL.
$currenturl = explode('?', 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$curpostId = url_to_postid($currenturl [0]);
$curpostId value will be zero if the current page is not a post / page.
$currenturl = explode('?', 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$curpostId = url_to_postid($currenturl [0]);
$curpostId value will be zero if the current page is not a post / page.
Tuesday, September 18, 2012
Subscribe to:
Posts (Atom)