[SOLVED] Conditional Tag to exclude widget
Hi-
What would be the conditional tag to exclude a widget on a specific page? For example, I wanted a widget to appear on all pages except a page with id "16". What would be the conditional tag for that? Thanks for your time! :) donny |
Ok it's not too hard, but some investigation is required.
Lets say you have an 'About' page and you have added the 'Meta' widget to the sidebars, but you don't want it to be displayed on the 'About' page. First you have to find out what page id the 'About' page is. Go to the WP dashboard and select pages. When you put your cursor over the 'About' link, you will see the page id in the address bar at the bottom (if you are displaying them). You can also go to the front end and go to the page in question and look at the HTML address. It should end in a number, this is the page ID. In this example we will say it is '2'. Next we need to find out the ID of the widget in question. If you view the source of the page you need to look thru till you find the left or right sidebar (depending on where the widget is) and then you will see something like this HTML Code:
<!-- Right Sidebar --> go to ATO-> HTML/CSS Inserts -> CSS Inserts and add the following HTML Code:
#body-page-NN #XXXXXX { display:none; } HTML Code:
#body-page-2 #meta { display:none; } |
Thank you Juggle!
I have "Widget logic" plug in on all my widgets, which allows you control the widget's behavior with conditional tags. Is there a conditional tag that can be used to exclude it from specific pages? :confused: |
If you follow the link on the "Widget logic"'s page in the line:
HTML Code:
The text field lets you use WP's Conditional Tags, or any general PHP code. I think the one you ate looking for is 'is_page('22') |
Juggle-
I think that tag is for including the widget only a specif page. 'is_page('22') would include the widget only on page "22". Is there a tag to include the widget on every page EXCEPT page "22"? Thank you for your help!! :) d |
is_page('22') = is page 22
!is_page('22') = is NOT ipage 22 |
Juggle!!
That WORKED!!! Thank YOU! :):):) One more question... If I wanted to exclude the home page too, what would be the tag? I used this code below, but it is not working for the home page, only page "22" : !is_page(array(22,'home')) What am I doing wrong? |
The page slug for your home page is probably not "home" but nothing ("/")
That "home" would work if you had a static front page and the blog home page was on a page with the page slug "home" http://www.yoursite.com/home/ Use !is_page('22') AND !is_home() for the (blog) home page, or !is_page('22') AND !is_front_page() for the front page |
Thanks Flynn!!! :)
This one worked. !is_page('22') AND !is_home() |
All times are GMT -6. The time now is 11:49 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.