So I have this chunk of PHP that excluded a certain element from appearing on all of my WordPress pages, while keeping them on posts/products, but there's a couple of pages where I would still like it to appear.
How do I go about excluding certain Page IDs from this query?
add_action( 'template_redirect', 'avada_check_page' );
function avada_check_page() {
if ( is_singular( 'page' ) ) {
add_action( 'avada_override_current_page_title_bar', 'avada_remove_title_bar' );
}
}
function avada_remove_title_bar() {
}
There's about 100 pages I want to apply this to and only 5 where I want to exclude them from this code.
A simple way would just be to use a condition on that first if statement.
add_action( 'template_redirect', 'avada_check_page' );
function avada_check_page() {
if ( is_singular( 'page' ) && !in_array(get_the_ID(),array(1,2,3,4)) ) {
add_action( 'avada_override_current_page_title_bar', 'avada_remove_title_bar' );
}
}
function avada_remove_title_bar() {
}
Where 1,2,3,4
place the exceptions posts ID's.
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.