hello,
this function code found @ https://kriesi.at/support/topic/possible-to-create-widget-area-above-footer
works great. but is there a way to have it like this on every page EXCEPT the homepage?
thanks!
add_action('ava_before_footer','avia_above_footer');
function avia_above_footer(){
dynamic_sidebar( 'CustomWidgetName' );
}
…and even better, if i can exclude any particular page based on the page ID number. that way i can exclude the home page as well as any other that i may want to.
thanks!
well, for lack of a better option, i used the page-specific ID’s in my custom CSS to hide what i’ve injected on every page from the homepage…
body.page-id-3662 .myclassname {
display: none;
}
if this isn’t an appropriate way to do all this, please let me know. otherwise, it seems to be working well.
Hi,
You can try something like this, if you want to exclude some pages:
add_action('ava_before_footer','avia_above_footer');
function avia_above_footer(){
if (! is_page(array( '42', 'home', '1026' ))) {
dynamic_sidebar( 'CustomWidgetName' );
}
}
You can use the slug of the page, or the ID: https://developer.wordpress.org/reference/functions/is_page/
Best regards,
Rikard
that’s good to know – thank you Rikard.
would it be better to do it like this or via css like i did? which is more proper/full-proof?
and, am i understanding correctly that the (! exclamation point is like saying “if is NOT these pages, then do…”?
thanks again.
Hi,
Thanks for the update. If you hide things with CSS, the source code is still on the page, but it’s not shown. If you exclude it using PHP, then it will never render. It’s up to your really, but the PHP solution might be the better choice.
And yes, the ! at the beginning means; if it’s not one of these pages, go ahead render the sidebar.
Best regards,
Rikard