Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Active class on buttons in WordPress

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #26242
    nutt318
    Member

    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

    #64779
    nutt318
    Member

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

    #64783
    blue642
    Member

    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:

    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.)

    #64785
    TheDoc
    Member

    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.

    #64805
    nutt318
    Member

    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.

    #64827
    nutt318
    Member

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

    Thanks Chris for that post.

    How do you mark post as solved?

    #64883
    TheDoc
    Member
    "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)
  • The forum ‘CSS’ is closed to new topics and replies.