{"id":354,"date":"2013-08-21T09:56:30","date_gmt":"2013-08-21T14:56:30","guid":{"rendered":"http:\/\/www.marcblase.com\/blog\/?p=354"},"modified":"2013-08-21T09:56:30","modified_gmt":"2013-08-21T14:56:30","slug":"force-page-template-on-child-pages-in-wordpress","status":"publish","type":"post","link":"https:\/\/ma.rcbla.se\/blog\/2013\/08\/force-page-template-on-child-pages-in-wordpress\/","title":{"rendered":"Force page template on child pages in WordPress"},"content":{"rendered":"<p>This is something that could come in handy. I&#8217;ve found a need for it in using the Nextgen Gallery plugin with the gallery page link setting enabled.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/\/ Force page template on child pages\r\n$page_children = get_pages('child_of=13');\r\nforeach($page_children as $child){\r\n\t$current_page_template = get_post_meta($child-&gt;ID,'_wp_page_template',true);\r\n\tif($current_page_template != 'page-OTHER_PAGE_TEMPLATE.php') update_post_meta($child-&gt;ID,'_wp_page_template','page-PARENT_PAGE_TEMPLATE.php');\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is something that could come in handy. I&#8217;ve found a need for it in using the Nextgen Gallery plugin with the gallery page link setting enabled. \/\/ Force page template on child pages $page_children = get_pages(&#8216;child_of=13&#8242;); foreach($page_children as $child){ $current_page_template = get_post_meta($child-&gt;ID,&#8217;_wp_page_template&#8217;,true); if($current_page_template != &#8216;page-OTHER_PAGE_TEMPLATE.php&#8217;) update_post_meta($child-&gt;ID,&#8217;_wp_page_template&#8217;,&#8217;page-PARENT_PAGE_TEMPLATE.php&#8217;); }<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-354","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/comments?post=354"}],"version-history":[{"count":1,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/354\/revisions"}],"predecessor-version":[{"id":355,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/354\/revisions\/355"}],"wp:attachment":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/media?parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/categories?post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/tags?post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}