M
M
mishapsv2013-12-05 17:33:06
PHP
mishapsv, 2013-12-05 17:33:06

Wordpress: how to set different backgrounds (and some data) for the main and other pages?

There is a template where on the main screen the first screen is a background image + a logo with a signature.
For the main one, it looks beautiful and harmonious.
But the problem is that it's the same for other pages. Those. the user goes to the cart or blog page and has to scroll through this header.
Can you please tell me how to remove this for all pages except the main one?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
mishapsv, 2013-12-05
@mishapsv

Thanks for the help, the following helped:
I determined that id="header is responsible for this and closed it with a function:

<?php woo_header_before(); ?>
<?php if ( is_home() ) { ?>   <!-- /#эта строка - начало -->
  <header id="header">
    <div class="col-full">
    
      <?php woo_header_inside(); ?>
      	
      	<div id="hgroup">
        <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
        <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
      </div>
      
      <?php if ( $settings['header_content'] != '' ) { ?>
        <p><?php echo do_shortcode( stripslashes( $settings['header_content'] ) ); ?></p>
      <?php } ?>
      
      <?php if ( is_woocommerce_activated() && isset( $woo_options['woocommerce_header_cart_link'] ) && 'true' == $woo_options['woocommerce_header_cart_link'] ) { ?>
        	<ul class="nav cart fr">
        		<li><a class="cart-contents" href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'woothemes' ); ?>"><?php echo sprintf( _n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes' ), $woocommerce->cart->cart_contents_count );?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a></li>
       		</ul>
      	<?php } ?>
          
    </div>
  </header><!-- /#header -->
<?php } ?> <!-- /#эта строка - конец функции-->
  <?php woo_content_before(); ?>

K
Konstantin Fedoev, 2013-12-05
@DiazMoS

Screenshot of the site in the studio.
Go to the folder with the template, usually \wp-content\themes\_name_of_your_template_
take a screenshot of the files there.

M
mishapsv, 2013-12-05
@mishapsv

Site
screenshot img.by/i/me62N.png
Screen of theme files
sg7fm.png

S
Supercharged, 2013-12-05
@Supercharged

I understand that the background is visible under the top menu, which is not necessary on secondary pages.
You can try using the following code in header.php:

if ( is_home() ) {
 ...верхнее меню с фоном...
} else {
 ... верхнее меню сокращенное...
}

M
mishapsv, 2013-12-05
@mishapsv

Phew, I opened the header.php file... it's not at all clear where to put this construction

?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php woo_title(); ?></title>
<?php woo_meta(); ?>
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>" />
<?php
wp_head();
woo_head();
?>
</head>
<body <?php body_class(); ?>>
<?php woo_top(); ?>
<div id="wrapper">
    
    <?php woo_header_before(); ?>

  <header id="header">
    <div class="col-full">
    
      <?php woo_header_inside(); ?>
      	
      	<div id="hgroup">
        <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
        <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
      </div>
      
      <?php if ( $settings['header_content'] != '' ) { ?>
        <p><?php echo do_shortcode( stripslashes( $settings['header_content'] ) ); ?></p>
      <?php } ?>
      
      <?php if ( is_woocommerce_activated() && isset( $woo_options['woocommerce_header_cart_link'] ) && 'true' == $woo_options['woocommerce_header_cart_link'] ) { ?>
        	<ul class="nav cart fr">
        		<li><a class="cart-contents" href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'woothemes' ); ?>"><?php echo sprintf( _n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes' ), $woocommerce->cart->cart_contents_count );?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a></li>
       		</ul>
      	<?php } ?>
          
    </div>
  </header><!-- /#header -->

  <?php woo_content_before(); ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question