is_page conditional question

I am using is_page in my functions.php file to display some code and I wanted only to display the code in the header if the contact page is being shown. I made a template called contact.php and in the top did the template name: contact. The templates shows just fine but when I went into the functions file and did is_page('contact') or is_page('contact.php') the code stopped working. Is the function based on the permalinks settings? right now I have wordpress setup for default so instead of showing contact.php in the address bar, it shows ?page_id=94. If I do is_page(94) then my test code works

Related posts

Leave a Reply

1 comment

  1. If the page slug is ‘contact’ then is_page(‘contact’) should work. You can check out the optional parameters for page in the codex here . Using post ID, e.g. 94 in your example will work regardless of permalink settings.

    If you want it to display for a specific template you can use is_page_template(‘contact.php’).