I'm working on creating my own WP template so I'm adjusting my pure HTML + CSS to work properly with WP. However, I have some issues with creating the separate blog page, which is not the main page. This is the result I want WP loop to generate for me:
<div class="news-body news-body1">
<div class="article-header">Title</div>
<div class="article-body"><img src="images/article1.jpg" alt="article1" id="text-image">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam suscipit placerat diam, ac sagittis felis ornare eget.</p>
</div>
<div class="article-readmore"><a href="#">Read more</a></div>
So this is what my PHP code looks like in the page template:
<? $postCount = 0; ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?if (++$postCount == 1) { ?>
<div class="news-body news-body1">
<?php } else { ?>
<div class="news-body">
<?php } ?>
<div class="article-header"><?php the_title(); ?></div>
<div class="article-body"><?php the_content(); ?></div>
<div class="article-readmore"><a href="<?php the_permalink(); ?>">Read More</a></div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center"><?php _e("Sorry, but you're looking for something else"); ?></p>
<?php endif; ?>
From what I know, this must work just right, showing 4 posts I already have put in the admin panel. But it doesn't work, the code that is being generated looks like this:
<div class="news-body news-body1">
<div class="article-header">News</div>
<div class="article-body"></div>
<div class="article-readmore"><a href="http://lol.ru/news">Read More</a></div>
</div>
</div>
What's my problem and how do I make it work? Thanks in advance!