How to show posts inside echo?
-
I want to display my posts in another layout on my front page than on my other post pages (/page/2, /page/3, etc.). I found the following code to check if the page is the front page:
<?php if( $_SERVER['REQUEST_URI'] == '/nieuws/' ) { echo ('<h3>home</h3>'); } else { echo ('<h3>page</h3>'); } ?>
This works, but when I put the code to display my posts inside the first echo, it doesn’t work anymore.
The code to display my posts looks like this (and works well):
<?php $postnum = 0; if (have_posts()) : ?> <?php while (have_posts()) : $postnum = $postnum + 1; the_post(); ?> <?php if ($postnum == 1 ) { ?> CODE FOR POST HERE <?php } ?> <?php if ($postnum == 2 ) { ?> CODE FOR POST HERE <?php } ?> <?php if ($postnum >= 3 ) { ?> CODE FOR POST HERE <?php } ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?>
Can somebody help me please?
- The topic ‘How to show posts inside echo?’ is closed to new replies.