• Resolved Abu Bakar

    (@absikandar)


    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

    (@wpyogi)

    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.

    Thread Starter Abu Bakar

    (@absikandar)

    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.

    WPyogi

    (@wpyogi)

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

    Thread Starter Abu Bakar

    (@absikandar)

    site is not live. It is in localhost.

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

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

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

    WPyogi

    (@wpyogi)

    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.

    Thread Starter Abu Bakar

    (@absikandar)

    Great.

    Thats what i need. Thank you for your help.

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