Hello friends, I have a small problem with getting the content from the pages in WordPress.
In my admin panel I have created some pages, also I have created a custom template and now when I want to open any of the pages then the content is not displayed (the content is empty). Only "Hello World" page works great (FrontPage or ?p=1), but the other pages (?p=4, ?p=6...) in admin panel have a content, but when I try to open in my website then the pages are without content (the content is empty).

For getting the content I use this function:

<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
   global $post;
   echo nl2br($post->post_content);
   // I tried with the_gontent() but I got the same problem.
?>				
<?php endwhile; ?>
<?php endif; ?>

How can I solve this problem ?

Thanks.

create single.php file on theme folder. and use this code:

<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php the_content('devamını oku &raquo;'); ?>
<?php endwhile; endif; ?>

If everything is ok, that means your post variable is empty. If not, you may change your static page. Control your settings from: http://www.yoursite.com/wp-admin/options-reading.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.