• I’m trying to add a Facebook and a Twitter icon to my homepage, without having them displayed on other pages. Below is my header.php file:

    <!DOCTYPE html>
    <html>
      <head>
        <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
        <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <link rel="shortcut icon" href="<?php echo bloginfo('template_directory') ?>/favicon.ico" type="image/x-icon" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <?php wp_head(); ?>
        <link rel="stylesheet" href="<?php bloginfo('template_directory') ?>/style_v6.css" type="text/css" media="screen" />
      </head>
      <?php
    $s = get_search_query();
    $s = '';
    if ($s != '') {
    ?>
      <body  onload="searchPrompt('<?php echo $s; ?>', false)">
    <?php
    } else {
    ?>
      <body >
    <?php
    }
      ?>
    <?php if (is_front_page()) { ?>
    <div id="slide">
    <?php putRevSlider("main_slider", "homepage") ?>
    </div>
    <?php } else { ?>
    <div id="slide-background">
    <img src="<?php echo content_url() . '/gallery/img/background-html.jpg' ?>" />
    </div>
    <?php } ?>
    
    <div id="wrap">
    <div id="<?php if (is_front_page()) { echo 'wrap-body-frontpage'; } else { echo 'wrap-body'; } ?>">
    <div id="<?php if (is_front_page()) { echo 'header-frontpage'; } else { echo 'header'; } ?>">
    <a href="<?php bloginfo('wpurl'); ?>"><h1>Corée Voyage</h1></a>
    <div id="main-social">
    <div id="header-sidebar">
    <ul>
    <li><a href="https://www.facebook.com/agencecoreevoyage" target="_blank"><div class="facebook-button" ></div></a></li>
    <li><a href="https://twitter.com/CoreeVoyage" target="_blank"><div class="twitter-button" ></div></a></li>
    <li></li>
    <?php dynamic_sidebar('header-sidebar'); ?>
    </ul>
    </div>
    </div> <!-- en main-social -->
    <?php wp_nav_menu('theme_location=header'); ?>
    </div> <!-- end header -->

    Any help would be greatly appreciated. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey coreevoyage,

    See this part in your header.php:

    <?php if (is_front_page()) { ?>
    <div id="slide">
    <?php putRevSlider("main_slider", "homepage") ?>
    </div>
    <?php } else { ?>
    <div id="slide-background">
    <img src="<?php echo content_url() . '/gallery/img/background-html.jpg' ?>" />
    </div>
    <?php } ?>

    This is a conditional statement that puts the Revolution Slider only on the home page.

    So, if you’re trying to do something similar for social icons, it could looks something like:

    <?php if (is_front_page()) { ?>
    
    HTML for icons goes here
    
    <?php } ?>

    Like maybe:

    <?php if (is_front_page()) { ?>
    
    <ul class="social-icons">
        <li class="facebook"><a href="#">Facebook</a></li>
        <li class="twitter"><a href="#">Twitter</a></li>
    </ul>
    
    <?php } ?>
    Thread Starter coreevoyage

    (@coreevoyage)

    Thanks a lot for your answer. I am indeed trying to implement the same function as the slider. However, your solution doesn’t seem to be working, since other conditional statements are being called below

    <div id="wrap">
    <div id="<?php if (is_front_page()) { echo 'wrap-body-frontpage'; } else { echo 'wrap-body'; } ?>">
    <div id="<?php if (is_front_page()) { echo 'header-frontpage'; } else { echo 'header'; } ?>">
    <a href="<?php bloginfo('wpurl'); ?>"><h1>Corée Voyage</h1></a>
    <div id="main-social">
    <div id="header-sidebar">
    <ul>
    <li><a href="https://www.facebook.com/agencecoreevoyage" target="_blank"><div class="facebook-button" ></div></a></li>
    <li><a href="https://twitter.com/CoreeVoyage" target="_blank"><div class="twitter-button" ></div></a></li>
    <li></li>
    <?php dynamic_sidebar('header-sidebar'); ?>
    </ul>
    </div>
    </div> <!-- end main-social -->
    <?php wp_nav_menu('theme_location=header'); ?>
    </div> <!-- end header -->

    Thanks again for your help!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding static image only on homepage’ is closed to new replies.