我正在使用wordpress作为我的网站的平台,我正在尝试添加一些自定义PHP文件,并保持所选主题使用的相同样式。
问题是网页的内容没有显示在网站上,虽然我为PHP文件创建了一个模板,然后我选择了创建的模板。
我所有的研究都表示,为了在wordpress中创建一个客户PHP文件,请:
将此代码添加到新文件的顶部
/ *
模板名称:templatename
* /
添加PHP代码
<?php
/**
* The template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package personalio
*/
/*
Template Name: ajwa2template
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
while ( have_posts() ) : the_post();
?>
<!--**********************************-->
<html>
<head>
<title>Form Validation</title>
<!-- Latest compiled and minified BootStarp CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function() {
jQuery("#textarea").hide()
jQuery("#droplistID").change(function() {
jQuery(this).val() == 'select' ? jQuery("#textarea").hide() : jQuery("#textarea").show();
});
});
</script>
</head>
<body>
<div id="page-wrapper">
<div class="container">
<form name="myForm" class="form-horizontal" id="myform" action="#" onsubmit="return submitForm();" method="POST" enctype="multipart/form-datam">
<div class="panel panel-info">
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name" class="col-md-4">Date *</label>
<div class="col-md-6">
<input type="text" class="form-control" id="name" name="name" placeholder="Enter Name" required/>
</div>
</div>
<div class="form-group">
<label for="Title" class="col-md-4">Title *</label>
<div class="col-md-6">
<input type="text" class="form-control" id="mobile" name="phone" placeholder="Enter the Title" required/>
</div>
</div>
<div class="form-group ">
<label for="category" class="col-md-4">select Category *</label>
<div class="col-md-6">
<select name="droplist" id="droplistID">
<option id = "option1" value="select" selected>Select</option>
<option id = "option2" value="category 1">category 34</option>
<option id = "option3" value="category 2">category 2</option>
<option id = "option4" value="category 3">category 3</option>
</select>
</div>
</div>
<div id="textarea">
<div class="form-group ">
<div class="col-md-6">
<textarea cols="60" rows="15" placeholder="enter a text "> </textarea>
</div>
</div>
</div>
<div class="form-group ">
<label for="image" class="col-md-4">Select Image </label>
<div class="col-md-6">
<input type="file" class="form-control" name="image">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-md-offset-4" style="margin-bottom: 50px;">
<center>
<input type="submit" class="btn btn-primary" value="Submit" />
</center>
</div>
</form>
</div>
</div>
</body>
</html>
<!--***************************************************-->
<?php
get_template_part( 'template-parts/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
答案 0 :(得分:0)
您的模板一切都有问题。 get_header()正在调用Doctype和head标签,可能还有一些东西。您在html文档中添加了另一个html文档。试试这个:
<?php
/**
* The template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package personalio
*/
/*
Template Name: ajwa2template
*/
get_header(); ?>
<script type="text/javascript">
jQuery(function() {
jQuery("#textarea").hide()
jQuery("#droplistID").change(function() {
jQuery(this).val() == 'select' ? jQuery("#textarea").hide() : jQuery("#textarea").show();
});
});
</script>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<!--**********************************-->
<div id="page-wrapper">
<div class="container">
<form name="myForm" class="form-horizontal" id="myform" action="#" onsubmit="return submitForm();" method="POST" enctype="multipart/form-datam">
<div class="panel panel-info">
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name" class="col-md-4">Date *</label>
<div class="col-md-6">
<input type="text" class="form-control" id="name" name="name" placeholder="Enter Name" required/>
</div>
</div>
<div class="form-group">
<label for="Title" class="col-md-4">Title *</label>
<div class="col-md-6">
<input type="text" class="form-control" id="mobile" name="phone" placeholder="Enter the Title" required/>
</div>
</div>
<div class="form-group ">
<label for="category" class="col-md-4">select Category *</label>
<div class="col-md-6">
<select name="droplist" id="droplistID">
<option id = "option1" value="select" selected>Select</option>
<option id = "option2" value="category 1">category 34</option>
<option id = "option3" value="category 2">category 2</option>
<option id = "option4" value="category 3">category 3</option>
</select>
</div>
</div>
<div id="textarea">
<div class="form-group ">
<div class="col-md-6">
<textarea cols="60" rows="15" placeholder="enter a text "> </textarea>
</div>
</div>
</div>
<div class="form-group ">
<label for="image" class="col-md-4">Select Image </label>
<div class="col-md-6">
<input type="file" class="form-control" name="image">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-md-offset-4" style="margin-bottom: 50px;">
<center>
<input type="submit" class="btn btn-primary" value="Submit" />
</center>
</div>
</form>
</div>
</div>
<!--***************************************************-->
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
?>
答案 1 :(得分:0)
Received: from localhost (unknown [10.91.142.1])
by local-mail.dev.com (Postfix) with ESMTPS
for receiver@receiver.local; Wed, 31 Jan 2018 11:37:10 +0000 (UTC)
Subject: Another Test Email With HTML body and mime type set from file body
From: sender@sender.local
Date: Wed, 31 Jan 2018 11:37:10 +0000
To: receiver@receiver.local
X-Mailer: @(#) mailsend v1.19 (Unix)
X-Copyright: BSD. It is illegal to use this software for Spamming
Mime-version: 1.0
Content-Type: (null); charset=utf-8