WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] if ... else custom code (7 posts)

  1. Abu Bakar
    Member
    Posted 1 year ago #

    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.?

  2. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    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.

  3. Abu Bakar
    Member
    Posted 1 year ago #

    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.

  4. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

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

  5. Abu Bakar
    Member
    Posted 1 year ago #

    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. http://www.w3schools.com/cssref/css_ref_aural.asp

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

  6. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    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.

  7. Abu Bakar
    Member
    Posted 1 year ago #

    Great.

    Thats what i need. Thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic