WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display different post style [css] in each category (17 posts)

  1. zzuum
    Member
    Posted 8 months ago #

    Hello,
    I want to display different post style [css] in each category.

    is it possible..?

    Thank you.

  2. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    check if your theme uses body_class() and/or post_class() which should give you category specific CSS classes;

    http://codex.wordpress.org/Function_Reference/body_class
    http://codex.wordpress.org/Function_Reference/post_class

  3. zzuum
    Member
    Posted 8 months ago #

    Ok, I use body class... It's my custome theme ..
    http://stefanvblog.com/category/news/

    How cna i modify posts with that.. :S ..and can you tell me why I don't see featured images on my posts :S ..

  4. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    my mistake - you will actually need to use post_class() so you can style the posts according to their category.

    see http://codex.wordpress.org/Function_Reference/post_class for the CSS classes that generated.

    why I don't see featured images on my posts

    are you using the corresponding function the_post_thumbnail() in the single.php template?

    with a custom theme, nobody but yourself will have access to the code, so any help through this forum will be very limited.

  5. zzuum
    Member
    Posted 8 months ago #

    I fix thumbnails but i still can't do that with different css style on categories... :(

    link : http://stefanvblog.com/category/news/

    can you explain me... I've been trying all day

  6. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    you seem to have succeeded in getting the background image to change for the different category archives.

    as for the individual posts, the CSS classes by post_class()) are for example in this line:
    <h2 id="post-570" class="post-570 post type-post status-publish format-standard hentry category-news tag-kitkat">

    what are you trying to format differently?

    to target the individual posts according to their category, try for example:
    .hentry.category-news { background: red; }

  7. zzuum
    Member
    Posted 8 months ago #

    I want my interview category be like this one on picture

    HERE

    Thank you for answer. :)

  8. zzuum
    Member
    Posted 8 months ago #

    Yes! i did it with you help! Thank you very much! :))

  9. zzuum
    Member
    Posted 8 months ago #

    can I change that thumbnail image with css too ?

    something like..

    .hentry.category-news.thumb { ... }

    this don't work.. do i need to add something els .. Thank you

  10. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    the element with the CS class .thumb is a different element from the one with the 'post_class()', therefore try:

    .hentry.category-news .thumb { ... }

  11. zzuum
    Member
    Posted 8 months ago #

    Thank you... Awesomee! :D

    I know this is not my question, but when you're already so good at this I must ask You just this.

    Do you know how to remove the text below title and that remain only Title and Thumbnail.

    on this link : http://stefanvblog.com/category/interview/

    Thank you for all :) You made my day :D

  12. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    the text will be from the code the_content() or the_excerpt() within your category.php or archive.php or index.php template; http://codex.wordpress.org/Template_Hierarchy

  13. zzuum
    Member
    Posted 8 months ago #

    I know.. it is from the_excerpt(), but when i delete that text disappear in all categories.. and I only need to disappear in categori-interview.

  14. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    try to change from:
    <?php the_excerpt(); ?>
    to:
    <?php if( !in_category( 'interview' ) ) the_excerpt(); ?>
    http://codex.wordpress.org/Function_Reference/is_category

  15. zzuum
    Member
    Posted 7 months ago #

    That's great.. Thank you!

    Can i have custom size of this thumbnail on this link..
    http://stefanvblog.com/category/interview/
    I create frame fot thumbnail..

  16. zzuum
    Member
    Posted 7 months ago #


  17. zzuum
    Member
    Posted 7 months ago #

    Thank you

Reply

You must log in to post.

About this Topic