{"id":1966,"date":"2015-06-23T13:05:08","date_gmt":"2015-06-23T13:05:08","guid":{"rendered":"http:\/\/www.websitedesignwebsitedevelopment.com\/?p=1966"},"modified":"2015-06-23T13:05:08","modified_gmt":"2015-06-23T13:05:08","slug":"how-to-apply-a-custom-header-image-for-each-page-in-wordpress","status":"publish","type":"post","link":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/","title":{"rendered":"How to apply a custom header image for each page in WordPress?"},"content":{"rendered":"<h2>How to apply a custom header image for each page in WordPress with respect to the navigation menu bar?<\/h2>\n<p><img decoding=\"async\" src=\"http:\/\/www.websitedesignwebsitedevelopment.com\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png\" \/><br \/>\nHere is the function:<br \/>\n<code>function get_parent_menu_id($id, $arr){<br \/>\nif($arr[$id]==0)<br \/>\nreturn $id;<br \/>\nelse<br \/>\nreturn get_parent_menu_id($arr[$id], $arr);<br \/>\n}<br \/>\n$arr = array();<br \/>\n$arr_obj = array();<br \/>\n$page_id = get_the_ID();<br \/>\n$menu_items = wp_get_nav_menu_items('Menu Main');<br \/>\nif(!empty($menu_items)){<br \/>\nforeach($menu_items as $items){<br \/>\n$parent = $items-&gt;menu_item_parent;<br \/>\n$arr[$items-&gt;ID] = $parent;<br \/>\n$arr_obj[$items-&gt;object_id] = $items-&gt;ID;<br \/>\n}<br \/>\n}<br \/>\n$parent_id = get_parent_menu_id($arr_obj[$page_id], $arr);<br \/>\n$arr_obj = array_flip($arr_obj);<br \/>\n$parent_id = $arr_obj[$parent_id];<br \/>\n<\/code><br \/>\n<code><br \/>\n&lt;div class=\"container_alpha slider\"&gt;<br \/>\n&lt;div style=\"clear:both\"&gt;<br \/>\n&lt;div&gt;&lt;img src=\"&lt;?php echo get_stylesheet_directory_uri().'\/images\/header_images\/'.$parent_id.'.jpg'; ?&gt;\" \/&gt;&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to apply a custom header image for each page in WordPress with respect to the navigation menu bar? Here is the function: function get_parent_menu_id($id, $arr){ if($arr[$id]==0) return $id; else return get_parent_menu_id($arr[$id], $arr); } $arr = array(); $arr_obj = array(); $page_id = get_the_ID(); $menu_items = wp_get_nav_menu_items(&#8216;Menu Main&#8217;); if(!empty($menu_items)){ foreach($menu_items as $items){ $parent = $items-&gt;menu_item_parent; $arr[$items-&gt;ID] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1967,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-1966","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to apply a custom header image for each page in WordPress? - AndroidBubble Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to apply a custom header image for each page in WordPress? - AndroidBubble Blog\" \/>\n<meta property=\"og:description\" content=\"How to apply a custom header image for each page in WordPress with respect to the navigation menu bar? Here is the function: function get_parent_menu_id($id, $arr){ if($arr[$id]==0) return $id; else return get_parent_menu_id($arr[$id], $arr); } $arr = array(); $arr_obj = array(); $page_id = get_the_ID(); $menu_items = wp_get_nav_menu_items(&#039;Menu Main&#039;); if(!empty($menu_items)){ foreach($menu_items as $items){ $parent = $items-&gt;menu_item_parent; $arr[$items-&gt;ID] [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"AndroidBubble Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-23T13:05:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png\" \/>\n\t<meta property=\"og:image:width\" content=\"952\" \/>\n\t<meta property=\"og:image:height\" content=\"324\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Fahad\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fahad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/\"},\"author\":{\"name\":\"Fahad\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"headline\":\"How to apply a custom header image for each page in WordPress?\",\"datePublished\":\"2015-06-23T13:05:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/\"},\"wordCount\":35,\"image\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png\",\"articleSection\":[\"Wordpress\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/\",\"url\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/\",\"name\":\"How to apply a custom header image for each page in WordPress? - AndroidBubble Blog\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png\",\"datePublished\":\"2015-06-23T13:05:08+00:00\",\"author\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"breadcrumb\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#primaryimage\",\"url\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png\",\"contentUrl\":\"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png\",\"width\":952,\"height\":324},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/androidbubble.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Website Development\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP Frameworks\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Wordpress\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How to apply a custom header image for each page in WordPress?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\",\"url\":\"https:\/\/androidbubble.com\/blog\/\",\"name\":\"AndroidBubble Blog\",\"description\":\"Articles &amp; Posts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/androidbubble.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\",\"name\":\"Fahad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"caption\":\"Fahad\"},\"sameAs\":[\"http:\/\/www.androidbubbles.com\/\",\"https:\/\/x.com\/phpFlex\"],\"url\":\"https:\/\/androidbubble.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to apply a custom header image for each page in WordPress? - AndroidBubble Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"How to apply a custom header image for each page in WordPress? - AndroidBubble Blog","og_description":"How to apply a custom header image for each page in WordPress with respect to the navigation menu bar? Here is the function: function get_parent_menu_id($id, $arr){ if($arr[$id]==0) return $id; else return get_parent_menu_id($arr[$id], $arr); } $arr = array(); $arr_obj = array(); $page_id = get_the_ID(); $menu_items = wp_get_nav_menu_items('Menu Main'); if(!empty($menu_items)){ foreach($menu_items as $items){ $parent = $items-&gt;menu_item_parent; $arr[$items-&gt;ID] [&hellip;]","og_url":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/","og_site_name":"AndroidBubble Blog","article_publisher":"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453","article_published_time":"2015-06-23T13:05:08+00:00","og_image":[{"width":952,"height":324,"url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png","type":"image\/png"}],"author":"Fahad","twitter_misc":{"Written by":"Fahad","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#article","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/"},"author":{"name":"Fahad","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"headline":"How to apply a custom header image for each page in WordPress?","datePublished":"2015-06-23T13:05:08+00:00","mainEntityOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/"},"wordCount":35,"image":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png","articleSection":["Wordpress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/","url":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/","name":"How to apply a custom header image for each page in WordPress? - AndroidBubble Blog","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png","datePublished":"2015-06-23T13:05:08+00:00","author":{"@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"breadcrumb":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#primaryimage","url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png","contentUrl":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png","width":952,"height":324},{"@type":"BreadcrumbList","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/how-to-apply-a-custom-header-image-for-each-page-in-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/androidbubble.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Website Development","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/"},{"@type":"ListItem","position":3,"name":"PHP Frameworks","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/"},{"@type":"ListItem","position":4,"name":"Wordpress","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/"},{"@type":"ListItem","position":5,"name":"How to apply a custom header image for each page in WordPress?"}]},{"@type":"WebSite","@id":"https:\/\/androidbubble.com\/blog\/#website","url":"https:\/\/androidbubble.com\/blog\/","name":"AndroidBubble Blog","description":"Articles &amp; Posts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/androidbubble.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7","name":"Fahad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","caption":"Fahad"},"sameAs":["http:\/\/www.androidbubbles.com\/","https:\/\/x.com\/phpFlex"],"url":"https:\/\/androidbubble.com\/blog\/author\/admin\/"}]}},"views":441,"jetpack_featured_media_url":"https:\/\/androidbubble.com\/blog\/wp-content\/uploads\/2015\/06\/air-lines.co_.uk_2015-06-23_18-04-33.png","_links":{"self":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/comments?post=1966"}],"version-history":[{"count":1,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1966\/revisions"}],"predecessor-version":[{"id":1968,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1966\/revisions\/1968"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media\/1967"}],"wp:attachment":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media?parent=1966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/categories?post=1966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/tags?post=1966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}