Forums

[resolved] Category class (11 posts)

  1. KEJNAV
    Member
    Posted 4 months ago #

    Hi,
    I have one problem.
    It's about CSS class of posts.
    All of my posts have same class , but only one category have a different.
    How I can , change that?
    I want to know , how to other categories have different class like that one? or How that category have same class as others...

    http://i.imgur.com/492Ks.png

  2. alchymyth
    The Sweeper
    Posted 4 months ago #

    what theme are you using?

    can you post a link to your site?

  3. KEJNAV
    Member
    Posted 4 months ago #

    It's custom built theme.
    Site http://skyinx.com/blog

  4. alchymyth
    The Sweeper
    Posted 4 months ago #

    your theme info says it is based on Twenty Ten;

    possibly look for loop.php of your theme;

    look for a line with <div class="post... and some more code;
    edit this accordingly.

    or possibly paste the full code of loop.php into a http://pastebin.com/ and post the link to it here.
    someone might have look at it and might be able to make some useful suggestions.

    and also try to contact who ever build that theme for you - this might be easier and faster.

  5. KEJNAV
    Member
    Posted 4 months ago #

    http://pastebin.com/eEsqRuKn
    I made that theme from this http://starkerstheme.com/ theme...

  6. alchymyth
    The Sweeper
    Posted 4 months ago #

    close to the beginning of the code, see these lines:

    <?php if ( in_category('3') ) { ?>
               <div class="post-cat-three">
     <?php } else { ?>
               <div class="post">
     <?php } ?>

    define what you would like instead, and edit the code.

    edit:
    the style.css does not seem to have any styles for .post-cat-three - therefore you could simplyfy the above code:

    <div class="post">
  7. KEJNAV
    Member
    Posted 4 months ago #

    in_category('3')

    Hmm when I delete this number , then all works fine with .post class.
    But I want to know what this number "in my case 3" do?
    Is it the number of category? If it is how to know number of category?

  8. alchymyth
    The Sweeper
    Posted 4 months ago #

    yes - 3 is the category ID of your category 'inspiration' or so.

    to find the category IDs of your categories, goto
    dashboard - posts - categories; and hover over the category names in the list, then look at the address bar at the bottom of the browser:
    it will show ........&tag_ID=3&..... where 3 is the category ID of the category where the mouse pointer hovers over.

    http://codex.wordpress.org/Function_Reference/in_category

  9. KEJNAV
    Member
    Posted 4 months ago #

    Ok Thank You.
    I think this will be last question :D
    How to add more of categories.
    I tried:

    <?php if ( in_category('3') ) { ?>
    <div class="post-cat-three">
    <?php if ( in_category('4') ) { ?>
    <div class="post-cat-four">
    <?php } else { ?>
    <div class="post">
    <?php } ?>

    then I tried:

    <?php if ( in_category('3') ) { ?>
    <div class="post-cat-three">
    <?php else ( in_category('4') ) { ?>
    <div class="post-cat-four">
    <?php } else { ?>
    <div class="post">
    <?php } ?>

    It doesn't work...
    How to add more categories with different class?

  10. alchymyth
    The Sweeper
    Posted 4 months ago #

    <?php if ( in_category('3') ) { ?>
    <div class="post-cat-three">
    <?php  } elseif ( in_category('4') ) { ?>
    <div class="post-cat-four">
    <?php } else { ?>
    <div class="post">
    <?php } ?>

    structure:

    if
    elseif
    elseif /*repeated as often as needed*/
    else

    http://php.net/manual/en/control-structures.elseif.php

  11. KEJNAV
    Member
    Posted 4 months ago #

Reply

You must log in to post.

About this Topic