The Widget Logic uses Conditional tags that controls where a widget should appear and conversely where it should not. We can write more than one conditional statements inside widget logic.
we’ll put our WordPress Conditional tags inside widget logic input filed as shown in figure.
Different Conditional statements syntax:
global $post;
if((is_page('page id') || ($post->post_parent=="page id"))){
return (is_page('page id') || ($post->post_parent=="page id"));
}
Display widget on page
is_front_page() : on front page.
is_home() : on home page.
is_page('page name') : on given page name.
is_page('page id') :on given page id.
is_page( array('abc', 'xyz', 50, 75) ) : on array of multiple pages.
is_front_page() || is_page('xyz') : on front page and xyz page
is_page('2715') || ($post->post_parent=="2715") : on page id 2715 and its sub-pages.
Display widget on Post
is_single('Abc') : on given post name.
is_single(451) : on given post id.
is_single( array('ABC', 45) ) : on array of multiple post name and id.
Display widget on Category
in_category('abc') : on given category name.
in_category( array('abc', 'xyx', 'Cat1') ) : on array of multiple category.
