如果是第一次发布,风格不同——Wordpress
问题描述:
我需要发布的第一篇文章具有不同的样式.有没有办法可以先查看帖子,然后再更改其内容?我目前在所有帖子中都有一个 div
.这个需要换成不同的div
.
I need the first post that was ever posted to be styled differently. Is there a way that I can see if the post is first, and then change its contents? I currently have a div
in all my posts. This needs to be replaced with different div
.
显然下面的一段代码可以提供帮助,但我不知道如何实现它:
Apparently the following piece of code can help, but I'm not sure how to implemenet it:
我是 WordPress 新手,所以不完全确定它是如何工作的?
I'm new with WordPress so not entirely sure how this could work?
答
在你的后面附加以下代码:
Append following codes after yours:
<?php if (have_posts()) : $postCount = 1; while (have_posts()) : $postCount++; ?>
<?php if($postCount == 2) { ?>
// SOMETHING TO DO WITH FIRST POST
<?php } else { ?>
// SOMETHING TO DO WITH ALL OTHER POSTS
<?php } ?>