0

I have a fully custom theme with a static front page and NO page set in Settings > Reading Settings > Front page displays as a posts page. However, I want to display certain posts (based on category) throughout the site on different static pages (and therefore, not have a set posts index page).

I injected this loop into one of those pages to test this out but got nothing but the page title. What am I doing wrong?

<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
        <p><?php the_time('F jS, Y') ?> by <?php the_author() ?></p>
    <?php endwhile; ?>
    <?php posts_nav_link('','','&laquo; Previous Entries') ?>
    <?php posts_nav_link('','Next Entries &raquo;','') ?>
    <?php else : ?>
        <h2>Not Found</h2>
        <?php _e("Sorry, but you are looking for something that isn't here."); ?>
<?php endif; ?>
1

Because you have not write any description function, thats why you are not getting any description of posts. This function is use to call the description of posts

the_content(__('Continue Reading'));

ABove function will show you complete post description But if you don't want to show whole post description and only want to show excerpt (few lines of description) then use this function instead

the_excerpt();

This function will show you few lines for posts. Add one of these function inside while loop (before endwhile;). To be more clear in you code the_title function is use to display the title of post and the_time and the_author function use to display post publish time and author of posts respectively. Add my given function after the_title function line or after the_author function line as per your requirement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.