{"id":623,"date":"2012-08-06T17:02:59","date_gmt":"2012-08-06T08:02:59","guid":{"rendered":"http:\/\/www.santoshkori.com\/blog\/?p=623"},"modified":"2012-08-06T17:02:59","modified_gmt":"2012-08-06T08:02:59","slug":"wordpress-get-parent-page-id-if-exists","status":"publish","type":"post","link":"https:\/\/www.santoshkori.com\/blog\/wordpress-get-parent-page-id-if-exists\/","title":{"rendered":"WordPress Get parent page ID if exists"},"content":{"rendered":"<p><strong>This is a great little wordpress snippet that will let you return the ID of the parent page if the page has a parent in wordpress<\/strong><\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\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\r\n?&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a great little wordpress snippet that will let you return the ID of the parent page if the page has a parent in wordpress &lt;?php function is_subpage() { global $post; if ( is_page() &amp;&amp; $post-&gt;post_parent ) { return $post-&gt;post_parent; } else { return false; } } ?&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,184],"tags":[294,295,293],"class_list":["post-623","post","type-post","status-publish","format-standard","hentry","category-wordpress","category-wordpress-tip-and-tricks","tag-get-parent-wordpress-page-id-if-exists","tag-get-parent-wordpress-page-id-if-exists-in-wordpress","tag-wordpress-get-parent-page-id-if-exists"],"_links":{"self":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/623","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=623"}],"version-history":[{"count":1,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/623\/revisions"}],"predecessor-version":[{"id":624,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/623\/revisions\/624"}],"wp:attachment":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/categories?post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/tags?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}