{"id":625,"date":"2012-08-06T17:06:34","date_gmt":"2012-08-06T08:06:34","guid":{"rendered":"http:\/\/www.santoshkori.com\/blog\/?p=625"},"modified":"2012-08-07T11:48:55","modified_gmt":"2012-08-07T02:48:55","slug":"return-id-of-the-parent-page-if-parent-page-exists-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.santoshkori.com\/blog\/return-id-of-the-parent-page-if-parent-page-exists-in-wordpress\/","title":{"rendered":"Return ID of the parent page if parent page exists in wordpress theme"},"content":{"rendered":"<p><strong>This is a great little snippet that will let you return the ID of the parent page if the page has a parent in wordpress<\/strong>.<br \/>\nJust add this snippet to the functions.php of your wordpress theme and your ready to get wordpress the parent page ID.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction is_subpage() {\r\n    global $post;\r\n    if ( is_page() &amp;&amp; $post-&gt;post_parent ) {\r\n        return $post-&gt;post_parent;\r\n    } else {\r\n        return false;\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a great little snippet that will let you return the ID of the parent page if the page has a parent in wordpress. Just add this snippet to the functions.php of your wordpress theme and your ready to get wordpress the parent page ID. function is_subpage() { global $post; if ( is_page() &amp;&amp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,184],"tags":[298,297,296,299],"class_list":["post-625","post","type-post","status-publish","format-standard","hentry","category-wordpress","category-wordpress-tip-and-tricks","tag-return-id-of-the-parent-page-if-parent-page-exists-in-wordpress","tag-wordpress-return-id-of-the-parent-page-if-parent-page-exists","tag-wordpress-return-id-of-the-parent-page-if-parent-page-exists-in-wordpress","tag-wordpress-return-id-of-the-parent-page-in-wordpress"],"_links":{"self":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/comments?post=625"}],"version-history":[{"count":4,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/625\/revisions"}],"predecessor-version":[{"id":627,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/625\/revisions\/627"}],"wp:attachment":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/media?parent=625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/categories?post=625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/tags?post=625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}