Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
same header image for parent and child pages
#1
How can I show a parent page header image in child pages as well? What code do I use?
Reply
#2
Can you explain more about your problem?

If the header image has to be in every page just add it in the template, if not you can add it in the editor..
Reply
#3
lucamusolesi Wrote:Can you explain more about your problem?

If the header image has to be in every page just add it in the template, if not you can add it in the editor..

Currentyl I am using this code for dynamic header images for individual pages.
Code:
<div id="headerpic"><img src="<?php get_site_url(); ?>data/uploads/headerpics/<?php get_page_slug(); ?>.jpg"></div>

But I want the child pages (and maybe third level pages as well) to have the same image as the parent page. How do I get that?
Reply
#4
andyash Wrote:Currentyl I am using this code for dynamic header images for individual pages.
Code:
<div id="headerpic"><img src="<?php get_site_url(); ?>data/uploads/headerpics/<?php get_page_slug(); ?>.jpg"></div>

But I want the child pages (and maybe third level pages as well) to have the same image as the parent page. How do I get that?

For second level pages change your code to:
Code:
<div id="headerpic">
  <img src="<?php get_site_url(); ?>data/uploads/headerpics/<?php !get_parent(false) ? get_page_slug() : get_parent(); ?>.jpg">
</div>

For all levels with the I18N plugin:
Code:
<div id="headerpic">
  <?php $bc = return_i18n_breadcrumbs(return_page_slug()); ?>
  <img src="<?php get_site_url(); ?>data/uploads/headerpics/<?php echo $bc[0]['url']; ?>.jpg">
</div>
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#5
This works great. Thanks.
Reply




Users browsing this thread: 1 Guest(s)