Grow your CSS skills. Land your dream job.

[Solved] Active class on buttons in WordPress

  • # September 25, 2009 at 9:01 am

    Hello, Just wanted to say hi. This is my first post and just wanted to say I’ve been watching a lot of the videos and have a question on one. It is video #7, with the rollover buttons. Anyways I am following Chris’s post on coding a custom css for wordpress and its going really good.

    So my problem is with assigning a body div id. Being I’m using WordPress, the index.php page stays the same. So how can I still accomplish this? Do I need to make actual separate pages for my main menu links, like about.php, projects.php, contact.php? Right now i have my links just go to that page post of /about/ or /projects/ or /contact/ and it work. I just cant figure out how to accomplish the active status with WordPress.

    Thanks for the help.
    Jake

    # September 28, 2009 at 9:24 am

    Anyone have any ideas on this one? Thanks for helping.

    # September 28, 2009 at 12:36 pm

    I believe the answer to your question is Yes, you would need to create the multiple pages.

    Basically, you could duplicate the index.php, to create each template page that you need (about.php, contact.php, etc.)

    For each page, you need to let Worpress know that they are template pages by placing code similar to this at the very beginning of the code:

    Code:
    < ?php
    /*
    Template Name: Homepage
    */
    ?>

    Naming them consistent with the page they will generate is probably best.

    -Then, in the WP admin, Click on "Pages"

    -When you see your list of pages, highlight over one and click "Quick Edit" for Template, choose your corresponding template.

    Also in the code of each one is where you’d want to change the body id per page.

    However, an easier solution (depending on your version of WordPress could be to use the wp_list_pages function. It will add a class current-page-item to the current page automatically. Just setup your styles for that class and you are done.

    (read about that here… http://codex.wordpress.org/Template_Tags/wp_list_pages It’s the last thing on the page.)

    # September 28, 2009 at 1:13 pm

    You don’t need to create new templates for them, and you shouldn’t.

    Your page.php should be able to handle this very easily. First with the option at the bottom of blue642′s post. Another option would be to attach the page’s id number to the body tag, thus allowing you to add styles according to that id.

    # September 28, 2009 at 11:39 pm

    Thanks for the help but looking at that link I am still lost as what to do or add into my code. Could someone give me an example of what I need to do?

    Thanks.

    # September 29, 2009 at 10:04 am

    I got it figured out, after enought googleing the top result was this. http://css-tricks.com/id-your-body-for- … ecificity/

    Thanks Chris for that post.

    How do you mark post as solved?

    # September 30, 2009 at 4:45 pm
    "nutt318" wrote:
    How do you mark post as solved?

    Just edit the title of the original post, but I hit it for ya.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".