简体   繁体   中英

exclude get_search_form from head of a certain page in Wordpress

I received this request from my client:

"We are still experiencing LOTS of problems with state aid recipients trying to log into their state aid account through the “My Account” function, even though you added language to direct them elsewhere. To solve this problem, would it be possible to remove the “Student Disability”, “Contact Us”, and “My account” links from the top of the State Aid pages? "

In researching and found that those links are generated in the searchform.php file of my theme.

How do I exclude that page from applying the get_search_form() function in the head.php ? This is what the navigation looks like with that function:

<div id="top-navigation">
    <?php get_search_form(); ?>
</div>

This is the site: http://Riseupms.com/state-aid/

Is it possible?

Assuming that the Page name of that particular page is "STATE FINANCIAL AID" you can do it like this

<?php if(!is_page( 'STATE FINANCIAL AID' ) { ?>
<div id="top-navigation">
    <?php get_search_form(); ?>
</div>
<?php } ?>

or you can exclude it by page id like this

<?php if(!is_page( 2341 ) { ?>
<div id="top-navigation">
    <?php get_search_form(); ?>
</div>
<?php } ?>

or u can simply do it with css

body.page.page-id-2341 #nav-bar li#item1,
body.page.page-id-2341 #nav-bar li#item2,
body.page.page-id-2341 #nav-bar li#item3 {
display:none;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM