1
votes

i have a WordPress template page, which shows header, footer and sidebar, but the content not showing up anyone can help?

<?php
/**
 * Template Name: Template 2
 */
?>

<?php get_header(); ?>

<div class="main_right" style="float:right;">
    <?php get_sidebar(1); ?>                        
 </div> 
<div style="float:left">    

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php echo the_content();?>

<?php endwhile; endif; ?>
</div>

<?php get_footer(); ?>
1
I don't think you need the "echo" - the_content() echoes the content automatically. Does it work if you remove it? - Hobo
i also tried with removing echo but no effect - Vidya L
hmm; it looks ok other than that. does your page have content? if you switch to another template does it appear? - Hobo

1 Answers

3
votes

Is this within your wordpress loop? It has to be in order for the_content to work.

Also, you don't need to echo the function, just place it in your file like so…

<?php the_content(); ?>

Also, why would you want to wrap the content in <p> tags? Wordpress does this for you automatically. If you want to wrap it something a <div> would be much better, probably with a class or id for css use.

Have you had a look at the wordpress codex? - http://codex.wordpress.org/Function_Reference/the_content