Get current page/post id in wordpress - Netgen IT Solutions

If you are customizing wordpress theme then many times you need to get current page id to show/hide some code or change basic functionality in wordpress. If you need the numeric id of the current page, you can get using following function in your wordpress theme file:


$currentid = get_the_ID();

After you have got the page id in $currentid you can easily use it in your php code like:

<?php if($currentid!=”4″)
//do Something
?>