coure2011
coure2011

Reputation: 42474

Create page from a template with customized body

Created a page template named page-person.php

<?php
/**
 * Template Name: Person Page
 * 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 mentorme
 */

get_header(); ?>  
        <div class="personality">
          <!-- dynamic content -->
          <?php the_content(); ?>
        </div>
    <?php get_footer(); ?>

Now I have added some test content, while creating the page from Template 'Person Page' like this enter image description here

but on page /dr-xyz its not showing text 'Testing' anywhere!

Upvotes: 0

Views: 38

Answers (2)

Fahad Sohail
Fahad Sohail

Reputation: 1846

You could use the_content to display your content and the_title() to display your post title. Try the following code

<?php get_header(); ?>
<div class="personality">
    <?php if (have_posts()) : 
        while (have_posts()) : the_post(); ?>
           <?php the_title(); ?>
           <?php the_content(); ?>
        <?php endwhile; ?>
    <?php endif; ?>
</div>
<?php get_footer(); ?>

Upvotes: 1

Ivan
Ivan

Reputation: 1

Try this

if ( have_posts() ) {
  while ( have_posts() ) {
    the_post(); 
    the_content();
  } // end while
} // end if

Upvotes: 0

Related Questions