Php wordpress的粘性贴子样式

Php wordpress的粘性贴子样式,php,html,css,wordpress,Php,Html,Css,Wordpress,添加的代码正确地添加了最近的三个便笺,但我希望以不同的方式设置这三个便笺的样式,而不是一行。有人能告诉我,我如何能参考每个贴子不同。我知道代码有点错误,因为它为每个粘性帖子分配了一个表,而我想将每个帖子添加为同一个表的元素 <?php get_header(); ?> <?php if(is_home() && !is_paged()) { ?> <?php query_posts(array('post__in'=>get_option('s

添加的代码正确地添加了最近的三个便笺,但我希望以不同的方式设置这三个便笺的样式,而不是一行。有人能告诉我,我如何能参考每个贴子不同。我知道代码有点错误,因为它为每个粘性帖子分配了一个表,而我想将每个帖子添加为同一个表的元素

<?php get_header(); ?>
<?php if(is_home() && !is_paged()) { ?>
<?php query_posts(array('post__in'=>get_option('sticky_posts'))); 
   $sticky = get_option( 'sticky_posts' );
   rsort($sticky);
   $sticky = array_slice( $sticky, 0, 3);
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) ); ?>
<?php while (have_posts()) : the_post(); ?>
    <table cellpadding="0" cellspacing="0" border="0" width="95%">
        <tr>
          <td valign="top">


<div class="masthead-1" style="float: left;">
            <?php if ( has_post_thumbnail() && ! post_password_required() && !is_attachment() ) : ?>

        <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_post_thumbnail(); ?>

    <?php endif; ?>
    <div class="mast11" style="opacity: 0.5;"></div>
              <div class="mast12">
                <h1 class="lbl2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><div style="clear:both"></div></h1>
              </div>
    </div></td></table>

<?php endwhile; ?>

如果您只需要知道第1、第2或第3个粘帖的编号,只需在while循环结束时添加一个递增的变量即可


无论如何,您可以在外部使用类包装器

<div class="specialsticky">

Your wordpress loop here

</div>
然后,您的表将附加一个特殊的post id,为每个新条目创建一个新的类样式


.specialsticky-192{如果只需要CSS样式,那么你的第一个选项肯定是正确的。我略读了一下这个问题,认为每个粘性都需要定制标记,这并不是一个真正的CSS唯一解决方案。我不相信第二个选项会有多大帮助,好像粘性注释经常被更改一样ing,那么所有的样式都将丢失,更不用说每个帖子都有那么多CSS规则会让人头疼……但我想OP可能已经将其视为一个解决方案!如果这是一个愚蠢的问题,我很抱歉,但是,使用您的第一个选项,CSS可以更改,但我是否能够将每个粘性帖子放在不同的单元格中表?我想你在这里问的问题是错误的。在你原来的问题中。要将它们全部放在表单元格中,请移出循环并与结束标记相同。如果我在问题中不清楚,我很抱歉,但是,我在问题中提到,代码将它们分别放在单独的表中,而我想将它们分别放在不同的表中同一个表的nt单元格最好使用div包装器并完全删除表。
<table class="specialsticky-<?php echo get_the_ID(); ?>" cellpadding="0" cellspacing="0" border="0" width="95%">