Ready to get started?Download WordPress


[resolved] Linking category links to CSS a: styles (5 posts)

  1. cambridge15
    Posted 2 years ago #

    Hey there, if anyone could help me i'd kiss you.. I'm going crazy!!

    I'm currently working on a new version of a site I run, NEATO

    Check it out here: http://www.neato.me/0915
    - You see the category links underneath each posts are different colors, the colors correspond with the side menu bar color.

    - THE PROBLEM: is they aren't linking to separate categories, clicking on Science, etc.. will always link to ALL

    Any solutions?

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    The first NEATO theme built from the ground up

    should be easy as this seems to be total custom theme:

    what is the coding (in index.php?) for those category links (in the 'postmetadata' div) below the posts on the front page?

    from the single posts, the categories are linking ok;
    possibly get the corresponding code from single.php and use it in index.php.

  3. cambridge15
    Posted 1 year ago #

    Hey there, thanks for the help.

    The single posts don't have the color-specific code yet. I've added it to make it easier.

    This is the code to change the category colors:

    <?php $the_cat = get_the_category(); $category_link = get_category_link( $the_cat[0]->cat_ID ); foreach((get_the_category()) as $category) { echo '<a class="'.$category->slug.'" href="'.$category_link.'">  '.$category->cat_name.'</a>' ; } ?> / <?php _e('by'); ?> <?php  the_author_link(); ?> /
                    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    no wonder - you are getting one fixed category link and using this for all categories;

    change the code to:

    <?php foreach( get_the_category() as $category ) { echo '<a class="'.$category->slug.'" href="'.get_category_link($category->term_id).'">  '.$category->cat_name.'</a>' ; } ?> / <?php _e('by'); ?> <?php  the_author_link(); ?> /
                    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
  5. cambridge15
    Posted 1 year ago #

    Wow you beautiful human!! Thank you!!

    Check it out! http://www.neato.me/0915/

    Thank you again,

Topic Closed

This topic has been closed to new replies.

About this Topic