ThemeShaper Forums » Thematic

Can I target .hentry for only category archive pages?

(5 posts)
  • Started 10 years ago by awarner20
  • Latest reply from amygail
  • This topic is not resolved
  1. Sorry if this is a simpleton question. I am using category archive template pages. I am trying to put the posts in a grid on these category pages. I have edited the .hentry and am successful, but it also affects the posts layout on the regular posts page (and regular page templates).

    Is there a way to target the .hentry on category pages only?

    Posted 10 years ago #
  2. Well, I accomplished my goal. I should have added above that I am also hooking into the category loop on these category page templates using the functions.php. So, here was how I solved my issue.

    My functions.php contains this:

    function remove_categoryloop() {
        remove_action('thematic_categoryloop', 'thematic_category_loop');
    }
    add_action('init', 'remove_categoryloop');
    
    function my_categoryloop() {
    while (have_posts()) : the_post(); ?>
    
            <div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>">
                  <?php thematic_postheader(); ?>
                  <div class="entry-content">
    <?php thematic_content(); ?>
    
    </div>
                  <?php thematic_postfooter(); ?>
              </div><!-- .post -->
    
          <?php endwhile;
    }
    add_action('thematic_categoryloop', 'my_categoryloop');

    So, I just changed the post class from this:

    <div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>">

    ...to this...

    <div id="post-<?php the_ID(); ?>" class="cat-page-posts">

    ...and then added:
    .cat-page-posts{
    }

    ...to my child theme stylesheet.

    Posted 10 years ago #
  3. amygail
    Member

    Glad you worked it out.

    You know that Thematic already generates dynamic classes for you, right?
    For instance, I use:

    body.category-gigs .hentry {}
    To style the archives page for the gigs category

    and
    body.s-category-gigs .hentry {
    display:none;

    }
    To style the individual posts in that cateory

    Posted 10 years ago #
  4. Hey amygail,

    Thanks for the tip, I wasn't aware of that, I'll keep that in mind if I need to change one or two category archive pages. I'm going to stick with my method above for now though because I need to style 85 category archive pages. Fortunately, they will all be styled the same:)

    Posted 10 years ago #
  5. amygail
    Member

    Hey, whatever works!

    You don't have to specify the category, you can style them all like this

    body.category .hentry {}
    To style the archives page for the gigs category

    and
    body.s-category .hentry {
    display:none;

    }

    Posted 10 years ago #

RSS feed for this topic

Reply

You must log in to post.