1

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

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

  • OH, that makes sense. Thaks for the tips. – Jamie Aug 1 '12 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.