Forums

[resolved] Declare CSS class to active link/page - HOW? (12 posts)

  1. 45Inches
    Member
    Posted 3 years ago #

    How can I give my active link/page a unique CSS class? I've tried to find ways to solve my issue on the internet, but no solution so far.

    Greetings from Denmark! :)

  2. t31os
    Member
    Posted 3 years ago #

    How are you generating the page links?

  3. 45Inches
    Member
    Posted 3 years ago #

    <?php wp_list_pages('title_li=&depth=1'); ?> :)

  4. t31os
    Member
    Posted 3 years ago #

    That function already gives classes to the elements...

    class="page-item-1 page_item" would be an example...

    A standard element is given 2 classes or 3 if active...

    Really you only need pay attention to 2, the following...

    page_item (this applies to a link)
    current_page_item (if the link is to the page you're already on)

    Just add the classes into the stylesheet.. example below..

    .page_item {
      color:#000
    }
    .current_page_item {
      color:#900
    }
  5. RobinKoorn
    Member
    Posted 2 years ago #

    <div class="submenu">
    		<?php
    		wpsc_start_category_query(array('category_group'=>get_option('wpsc_default_category'), 'show_thumbnails'=> false)); ?>
    		<ul>
                <li class="menu-item">
                    <a href='<?php wpsc_print_category_url();?>' class='wpsc_category_link'><?php wpsc_print_category_name();?></a>
                    <?php wpsc_print_subcategory('<ul>', '</ul>'); ?>
                </li>
            </ul>
    	<?php wpsc_end_category_query(); ?>
    	</div>

    This is my code for a menu, how can i change the color of the active page?

    Thanks!

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    in style.css

    look for (or add)

    .current_page_item {
      color:#900
    }

    adjusting the colour as needed (as @t31os advised)

  7. RobinKoorn
    Member
    Posted 2 years ago #

    thanks for your reaction but i don't have a

    .current_page_item

    in my style.css

  8. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    right....like I said...

    look for (or add)

    you can paste that bit of code from above anywhere in style.css, and then adjust the colour....sometimes you have to add your own things in there

  9. RobinKoorn
    Member
    Posted 2 years ago #

    i'm sorry i overlooked that..

    I add the code but it still doesn't work :S

    http://www.designmaxx.nl/
    When you click on 'banken' in the footer menu, there will be no change in the color.

  10. Edward Caissie
    Member
    Posted 2 years ago #

    Based on your examples above and viewing the source code on your site, it appears the function wpsc_print_subcategory() is generating your page links in the footer.

    You may need to look at modifying that function to add a class (or two?) around your page links, then use @t31os_ or @RVooDoo suggestions.

  11. RobinKoorn
    Member
    Posted 2 years ago #

    Ok thanks
    but how should i do that?

    My php knowledge is not that good :S

    function wpsc_print_subcategory($start_element = '', $end_element = '') {
      global $wpsc_category_query;
      $wpsc_category_query['subcategory_container'] = array('start_element' => $start_element, 'end_element' =>  $end_element);
      echo "[wpsc_subcategory]";
    }
  12. Edward Caissie
    Member
    Posted 2 years ago #

    Although just a guess, it appears the wpsc_category() function is part of the WP-eCommerce plugin. If so, you may want to contact the plugin author for help specific to it.

Topic Closed

This topic has been closed to new replies.

About this Topic