Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
OH, that makes sense. Thaks for the tips. –  Jamie Aug 1 '12 at 1:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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