I am using wordpress as a platform for my website where i am trying to add some custom PHP files with keeping the same style used on the selected theme.
The problem is that the content of the webpage is not showed up on the website, although I created a template for the PHP file and i select the created template.
All my researches say that in order to create a custome PHP file in the wordpress is to :
- duplicate the page.php
add this code at the top of the new file
/*
Template Name: templatename
*/
add the PHP code
code:
<?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();