Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How would you approach this? Wordpress

Featured Replies

Hey guys,

 

Looking for some advice on a site I'm building for a client, scratching my head about the best way to approach this problem.

 

My basic layout looks like:

 

[Logo] - [Navigation]

 

[big Image]

 

[Testimonial Slider]

 

[Content]

 

I've put the Logo, Nav, Big Image and Testimonials in the Header.php file, so it's the same across all pages, simple!

 

But now the client says they want a different image on every page! (6 pages)

 

And I'm debating the best way to do this?

 

Is there a way of avoiding having to make a custom template for every different page?

 

Thanks,

Chris

Wordpress puts classes on the body tag, use css to set the image url depending on each page's body class

  • Author

How would you do that in CSS? Set it up as a background image and do it that way? So

 

Body.ClassName BigImage { bakground-image:url('url.jpg'); } - something a long those lines?

 

Thanks for your quick response!

You could do it with CSS, by changing the background image of a HTML tag according to the body class.

 

To get the classes applied to the body tag, do this:

 

<body <?php body_class();?>>

 

Another way of doing it, is, using the is_page() template tag, e.g:

 

<?php if ( is_page('About') ) { ?>
   <img src="<?php bloginfo('template_url')?>/images/about.gif" title="" />
<?php } ?>
<?php if ( is_page('Contact') ) { ?>
   <img src="<?php bloginfo('template_url')?>/images/contact.gif" title="" />
<?php } ?>

Edited by Pedro

Body.ClassName BigImage { bakground-image:url('url.jpg'); } - something a long those lines?

 

Essentially yes.

 

body.pagename1 .mainimage {background-image:url('url1.jpg');}
body.pagename2 .mainimage {background-image:url('url2.jpg');}
body.pagename3 .mainimage {background-image:url('url3.jpg');}
body.pagename4 .mainimage {background-image:url('url4.jpg');}

 

etc...

 

 

Another way of doing it, is, using the is_page() template tag, e.g:

 

<?php if ( is_page('About') ) { ?>
   <img src="<?php bloginfo('template_url')?>/images/about.gif" title="" />
<?php } ?>
<?php if ( is_page('Contact') ) { ?>
   <img src="<?php bloginfo('template_url')?>/images/contact.gif" title="" />
<?php } ?>

 

This is how I originally thought to do it and it does the same job, just more to write

  • Author

Thanks for your help, the classes might be simpler for me :) But thanks!

Use the page's featured image. Set a custom size for it in your theme's functions.php, and you can get the featured image outside of the Loop by passing $post->ID.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.