Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I try to make template that has Page content in the main div but in the same page there is category base post loop whit title, day, content and read more link.

What i had now is like this

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

    <?php
    //Post thumbnails need this in functions.php: `add_theme_support('post-thumbnails');`
    if(has_post_thumbnail()) the_post_thumbnail(array(100,100));
    ?>

    <h1><?php the_title(); ?></h1>
    <?php the_content(); ?>



    <?php endwhile; ?>
    <?php else: ?>
    <!-- No posts found -->
    <?php endif; ?>

and to post the category loop is this.

<?php $my_query = new WP_Query( "cat=4" );
       if ( $my_query->have_posts() ) { 
           while ( $my_query->have_posts() ) { 
               $my_query->the_post();



                 echo '<div id="blogi_loop">';
                 echo '<h1>';
                the_title();
                echo '</h1>';
                the_date('m.d.Y');

               the_content();

               echo '</div>';              }
       }
       wp_reset_postdata();
    ?>

How ever i see only one day format in the loop? And how i see the read more link?

share|improve this question
add comment

3 Answers

Use the_excerpt() instead of the_content() - the_content() will only cut off if you do it manually.

share|improve this answer
    
Chirs thanks. How about the_date it show only in the firs loop? –  vj_andrei Feb 16 '12 at 14:45
add comment

As Chris has mentioned you want to be using the_excerpt() rather than the_content().

As for the date issue, see this Codex page, in particular:

SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string. Use <?php the_time(get_option('date_format')); ?> to add the date set in the admin interface.

See the_time() or get_the_date() Codex pages.

share|improve this answer
    
Thank you Stephen. Now i got it working. –  vj_andrei Feb 16 '12 at 14:54
1  
Please mark answers as correct if they solve your problem. It means your question gets taken off the 'unanswered' pile, and makes it easier for others to recognize what worked for you. –  Stephen Harris Feb 16 '12 at 15:02
    
@vj_andrei, I meant tick the answer :D. There is a tick to the left of each question, click the one that corresponds to answer that solved your question. –  Stephen Harris Feb 17 '12 at 17:33
add comment
You can try this loop for category post.
<?php $my_query = new WP_Query( "cat=4" );
   if ( $my_query->have_posts() ) { 
       while ( $my_query->have_posts() ) { 
           $my_query->the_post();



             echo '<div id="blogi_loop">';
             echo '<h1>';
            the_title();
            echo '</h1>';
            the_date('m.d.Y');

           the_excerpt();

           echo '</div>';              }
   }
   wp_reset_postdata();
?>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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