Support » Themes and Templates » [Resolved] if … else custom code

[Resolved] if … else custom code

  • Hi guys.

    I am trying to put a code in footer.php.

    My site have 5 pages.It has a contact form in footer. And i want the contact form to be appear on all pages except last page “Contact us”. Where i will put the form in main content area. I do not want the footer form to show up in contact us page. How can i do this?

    In the footer.php , how can i put if … else code for this.?

Viewing 6 replies - 1 through 6 (of 6 total)
  • WPyogi


    Forum Moderator

    It might be easier to do this in the CSS code — using a page specific selector to target that page only — and then using display: none; on the contact form in the footer.

    Thank you for the reply. Can you tell me how it will go ?
    I don’t know how to apply page selectors in css

    Thank you for your help.



    Forum Moderator

    Can’t help without seeing the site…and the page in question.

    site is not live. It is in localhost.

    the page which i want to not show the form is /contact-us/
    Other pages are.
    About us

    I know CSS but never used Page selector tag. Here on W3C school. I can not fine the appropriate page selector tag. http://www.w3schools.com/cssref/css_ref_aural.asp

    Do you know any link where I can read about it ?



    Forum Moderator

    It’s not a specific type of selector — it’s a concept. Most themes assign a unique class or id to each page – often something like:

    <body class="page-id-27">

    So then you can use that in the CSS to target that page only — combined with the class for the form you want to hide on that page only it might be like this:

    body.page-id-27 #footer .myform {
       display: none;

    Note that these are made up selectors — you’ll need to use ones that are relevant to your site.


    Thats what i need. Thank you for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] if … else custom code’ is closed to new replies.