• Resolved 45inches

    (@45inches)


    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! ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • t31os

    (@t31os)

    How are you generating the page links?

    Thread Starter 45inches

    (@45inches)

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

    t31os

    (@t31os)

    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
    }
    <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!

    in style.css

    look for (or add)

    .current_page_item {
      color:#900
    }

    adjusting the colour as needed (as @t31os advised)

    thanks for your reaction but i don’t have a

    .current_page_item

    in my style.css

    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

    i’m sorry i overlooked that..

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

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

    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.

    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]";
    }

    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.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Declare CSS class to active link/page – HOW?’ is closed to new replies.