【发布时间】:2012-11-14 04:10:30
【问题描述】:
我有 2 个循环来显示粘性帖子(循环 1)和所有帖子(循环 2)。粘性帖子的样式与循环 2 的帖子不同。现在我在代码中添加了posts_nav_link();,以便每页仅显示循环 2 的 6 个帖子。导航有效,但是当我导航粘性帖子时,仅在第一页上的样式正确。
我将粘性帖子的样式设置为:
HTML:
<?php // div class for styling sticky posts. ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); // Show summary of posts only. ?>
</div> <!-- end class sticky -->
CSS:
.sticky {
border: 1px solid black;
background-color: white;
width: 200px;
}
第一页的HTML(带有萤火虫):
<div class="blogpost">
<div id="post-324" class="post-324 post type-post status-publish format-standard sticky hentry category-uncategorized">
<h2>
<a title="This is a sticky post" href="http://mywebsite.com/?p=324">This is a sticky post</a>
</h2>
<p>
Written on 10/08/2012. Filed under
<a rel="category" title="View all posts in Uncategorized" href="http://mywebsite.com/?cat=1">Uncategorized</a>
.
</p>
<p>
Content of the post.
<a href="http://mywebsite.com/?p=324">[Read more ...]</a>
</p>
</div>
</div>
所有其他页面上的 HTML(带有萤火虫): (在我看来是一样的。)
<div class="blogpost">
<div id="post-324" class="post-324 post type-post status-publish format-standard hentry category-uncategorized">
<h2>
<a title="This is a sticky post" href="http://mywebsite.com/?p=324">This is a sticky post</a>
</h2>
<p>
Written on 10/08/2012. Filed under
<a rel="category" title="View all posts in Uncategorized" href="http://mywebsite.com/?cat=1">Uncategorized</a>
.
</p>
<p>
Content of the post.
<a href="http://mywebsite.com/?p=324">[Read more ...]</a>
</p>
</div>
</div>
有没有一种方法可以在导航时在每个页面上显示带有自己 CSS 的帖子?
【问题讨论】:
-
点击第二页后,wordpress 为您提供的 html 是什么样的?
-
我编辑了我的问题并添加了代码。
-
缺少样式表或缺少更多全局选择器?在 firebug 中选择类
blogpost的 div 并查看两个页面中的面包屑。是一样的吗? CSS 选项卡中是否有相同的 CSS 文件?
标签: css wordpress posts sticky