联系表格7显示在标题上方

时间:2016-04-06 18:08:22

标签: php wordpress

出于某种原因,我的联系表格显示在我的wordpress标题上方,如下所示:

enter image description here

这是我的代码:

<?php

   /**
 * Template Name: Contact Us
 *
 * @package WordPress
 * @subpackage Creativeforces
 * @since  Creativeforces Group 1.0
 */

 ?>
<head>
    <meta charset="utf-8">
    <title>Creative Forces | Contact Us</title>
    <link rel="stylesheet" type="text/css" href="/wp-content/themes/creativeforces/css/contact.css">
    <link href='https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700' rel='stylesheet' type='text/css'>
</head>


<header>
        <?php while ( have_posts() ) : the_post() ?>
            <?php the_content(); ?>
        <?php endwhile; ?>
         <?php get_sidebar(); ?>
</header> 

   <?php get_header(); ?>



   <?php get_footer(); ?>

在wordpress admin的联系页面上我有短代码:

[contact-form-7 id="131" title="Contact form 1"]

这里需要header.php id:

<?php 
/**
 * The template for displaying the header
 *
 * Displays all of the head element and everything up until the "site-content" div.
 *
 * @package WordPress
 * @subpackage Creativeforces
 * @since Creativeforces 1.0
 */

?>
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">


    <meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
  <script type="text/javascript" src="https://js.stripe.com/v2/"></script>


    <?php wp_head(); ?>

    <link rel="alternate" type="application/rss+xml" href="<?php bloginfo('rss2_url'); ?>" title="<?php printf( __( '%s latest posts', 'your-theme' ), wp_specialchars( get_bloginfo('name'), 1 ) ); ?>" />
    <link rel="alternate" type="application/rss+xml" href="<?php bloginfo('comments_rss2_url') ?>" title="<?php printf( __( '%s latest comments', 'your-theme' ), wp_specialchars( get_bloginfo('name'), 1 ) ); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

</head>

<body data-spy="scroll" data-target=".navbar">


<div class="black-line"></div>


          <!-- LOGO -->
           <?php if ( get_theme_mod( 'themeslug_logo' ) ) : ?>
    <div class='site-logo'>
        <a href='<?php echo esc_url( home_url( '/' ) ); ?>' title='<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>' rel='home'><img src='<?php echo esc_url( get_theme_mod( 'themeslug_logo' ) ); ?>' alt='<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>'></a>
    </div>
<?php else : ?>

    <!-- Displayes blog title and description -->
    <hgroup>
        <h1 class='site-title'><a href='<?php echo esc_url( home_url( '/' ) ); ?>' title='<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>' rel='home'><?php bloginfo( 'name' ); ?></a></h1>
        <h2 class='site-description'><?php bloginfo( 'description' ); ?></h2>
    </hgroup>
<?php endif; ?>

                <!--  Top-Nav-Menu -->
<div id="menu" class="navbar text-center">

    <?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header', 'container' => 'nav', 'theme_location' => 'header-menu',  'walker' => new wp_bootstrap_navwalker()) ); ?>


</div>

任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:0)

你已经在the_content()之后放置了wp_header() 它应该贴在标签旁边。

一般情况就像 - - 标题 - 内容 - 页脚

以下是修改后的代码 -

<?php

   /**
 * Template Name: Contact Us
 *
 * @package WordPress
 * @subpackage Creativeforces
 * @since  Creativeforces Group 1.0
 */

 ?>
<head>
    <meta charset="utf-8">
    <title>Creative Forces | Contact Us</title>
    <link rel="stylesheet" type="text/css" href="/wp-content/themes/creativeforces/css/contact.css">
    <link href='https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700' rel='stylesheet' type='text/css'>
</head>

<body>

<header>
        <?php get_header(); ?>
</header> 

   <?php while ( have_posts() ) : the_post() ?>
            <?php the_content(); ?>
        <?php endwhile; ?>
         <?php get_sidebar(); ?>


<footer>
   <?php get_footer(); ?>
</footer>

答案 1 :(得分:0)

您正在标题部分中添加内容/侧边栏,之后添加了此标题,这就是您的联系表单7出现在标题上方的原因。

请尝试这样

    <header>
      <?php get_header(); ?>
    </header> 
    <div class="contentdiv">
     <?php while ( have_posts() ) : the_post() ?>
     <?php the_content(); ?>
     <?php endwhile; ?>
     <?php get_sidebar(); ?>
    </div>