仅在主页上显示图像滑块

时间:2014-05-25 作者:user3528624

我在wordpress主题中放置了一个图像滑块,但它显示在所有页面上。我只希望它显示在我的主页上。

这是我在标题中的代码。php子主题

<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="content">
 *
 * @package GovPress
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( \'charset\' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php wp_title( \'|\', true, \'right\' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( \'pingback_url\' ); ?>">
<!--[if lt IE 9]>
<script src="<?php echo esc_url( get_template_directory_uri() . \'/js/html5.js\' ); ?>"></script>
<![endif]-->
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
<div id="page" class="hfeed site">

    <?php do_action( \'before\' ); ?>

    <nav id="site-navigation" class="main-navigation" role="navigation">
        <div class="col-width">
            <h1 class="menu-toggle"><?php _e( \'Menu\', \'govpress\' ); ?></h1>
            <a class="skip-link screen-reader-text" href="#content"><?php _e( \'Skip to content\', \'govpress\' ); ?></a>

            <?php wp_nav_menu( array(\'theme_location\' => \'primary\', \'menu_class\' => \'nav-menu\' ) ); ?>
        </div>
    </nav><!-- #site-navigation -->
<div class="headerslider"> <?php echo do_shortcode(\'[sp_responsiveslider limit="-1"]\'); ?></div>
    <header id="masthead" class="site-header" role="banner">
        <div class="site-branding col-width">

            <?php if ( get_header_image() ) : ?>
                <a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" rel="home">
                    <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="">
                </a>
            <?php endif; // End header image check. ?>
            <h1 class="site-title"><a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" rel="home"><?php bloginfo( \'name\' ); ?></a></h1>
            <h2 class="site-description"><?php bloginfo( \'description\' ); ?></h2>
        </div>
    </header><!-- #masthead -->

    <?php if ( is_page_template(\'templates/home-page.php\') ) {
        get_template_part( \'templates/above\', \'home-page\' );
    } ?>

    <div class="col-width">
        <div id="content" class="site-content">

1 个回复
SO网友:user3635808

Try this

<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="content">
 *
 * @package GovPress
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( \'charset\' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php wp_title( \'|\', true, \'right\' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( \'pingback_url\' ); ?>">
<!--[if lt IE 9]>
<script src="<?php echo esc_url( get_template_directory_uri() . \'/js/html5.js\' ); ?>"></script>
<![endif]-->
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
<div id="page" class="hfeed site">

    <?php do_action( \'before\' ); ?>

    <nav id="site-navigation" class="main-navigation" role="navigation">
        <div class="col-width">
            <h1 class="menu-toggle"><?php _e( \'Menu\', \'govpress\' ); ?></h1>
            <a class="skip-link screen-reader-text" href="#content"><?php _e( \'Skip to content\', \'govpress\' ); ?></a>

            <?php wp_nav_menu( array(\'theme_location\' => \'primary\', \'menu_class\' => \'nav-menu\' ) ); ?>
        </div>
    </nav><!-- #site-navigation -->

    <?php if (is_front_page()){ ?> 
    <div class="headerslider">
    <?php echo do_shortcode(\'[sp_responsiveslider limit="-1"]\'); ?>
    </div>
    <?php  } ?>

    <header id="masthead" class="site-header" role="banner">
        <div class="site-branding col-width">

            <?php if ( get_header_image() ) : ?>
                <a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" rel="home">
                    <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="">
                </a>
            <?php endif; // End header image check. ?>
            <h1 class="site-title"><a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" rel="home"><?php bloginfo( \'name\' ); ?></a></h1>
            <h2 class="site-description"><?php bloginfo( \'description\' ); ?></h2>
        </div>
    </header><!-- #masthead -->

    <?php if ( is_page_template(\'templates/home-page.php\') ) {
        get_template_part( \'templates/above\', \'home-page\' );
    } ?>

    <div class="col-width">
        <div id="content" class="site-content">
结束

相关推荐

如何在没有`Headers已发送`错误的情况下同时使用`wp_INSERT_USER`和`wp_INSERT_POST`?

我正在使用创建前端过帐表单wp_insert_post 这要求用户输入三个基本字段:他们的名字、姓氏和电子邮件地址。如果用户已登录,我会预先填充文本字段,并在提交表单时忽略它们。但是,如果用户未登录,“我的功能”会检查if the email entered is registered. 如果是,函数将获取关联的user\\u id并将该用户指定为post\\u作者。如果电子邮件未关联,则通过以下方式创建新用户wp_insert_user.表单返回此错误:Warning: mysql_real_escap