8 Comments

  1. I was doing this the “hard way”, and never thought of using a function..
    Thanks for the tip!

  2. No problem, glad I could offer the idea. I did it the other way for quite a while which is just as useful but as I have started to use this quite a bit more often I finally realized it just made sense to drop it in the functions file, keeps it a bit more organized especially if you are using more than #home and #single. Nice thing is that it is now pretty portable and easy to use on the next project.

  3. Jeremy, this is a clever approach. An idea like this just might be a foundation for a plugin that allows WP sites to have a “theme switcher”… for example, to allow users to click on an accessibility link that would alter a site’s theme with enhanced contrast and larger font size. Just an idea.

    I also noticed that you mentioned you have very little free time in posting your thisdayindesign post. Are you in need of extra WP coding hands??

  4. I was just wondering how you would apply this with custom page templates.

    So if i added a custom page template called “extra page”, what wordpress functions would i use to search specific pages?

  5. @Nils – Good question, you could either use the given name of the page like this:
    if is_page(‘page-name’)
    or you could use the page ID like this:
    if is_page(‘12′)
    or I believe you could use the to check for a specific template
    if is_page_template(‘extra-page.php’)
    For more information on WordPress Conditional Tags check this page http://codex.wordpress.org/Conditional_Tags and let me know what works for you as I do not actually have the time to test that right now, but I believe that is what you are looking for.

  6. The last comment #5 was exactly what I was looking for. And it works perfectly. Thank you!

  7. @Christy Glad to hear it works and glad I could help out. I was pretty certain it would work but as I said it was untested so thanks for dropping by and letting me know.

  8. @Jeremy -
    So the way i asked does work great, thank you.

    And the ‘is_page’ function specifically looks for this:
    is_page(‘about-me’)
    When the Page with a post_name (slug) of “about-me” is being displayed.

    This is the function that i made with your tutorial and help.

Leave a Comment




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>