Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Sidebars & Widgets »

[SOLVED] Conditional Tag to exclude widget


  #1  
Old May 29, 2009, 11:21 AM
d_random
 
51 posts · Apr 2009
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
  #2  
Old May 31, 2009, 06:20 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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 -->
<td id="right">

	<div id="meta" class="widget widget_meta">			<div class="widget-title"><h3>Meta</h3></div><div class="widget-content">			<ul>
		<li><a href="http://192.168.48.99/~paul/zenofmud/wp-admin/">Site Admin</a></li>			<li><a href="http://192.168.48.99/~paul/zenofmud/wp-login.php?action=logout&amp;_wpnonce=4c3f0aa1d6">Log out</a></li>
		<li><a href="http://192.168.48.99/~paul/zenofmud/?feed=rss2" title="Syndicate this site using RSS 2.0">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li>
		<li><a href="http://mydomain.com/?feed=comments-rss2" title="The latest comments to all posts in RSS">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li>
		<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li>
						</ul>
		</div></div><div id="archives" class="widget widget_archive"><div class="widget-title"><h3>Archives</h3></div><div class="widget-content">		<ul>
			<li><a href='http://mydomain.com/?m=200905' title='May 2009'>May 2009</a></li>
	<li><a href='http://mydomain.com/?m=200904' title='April 2009'>April 2009</a></li>
	<li><a href='http://mydomain.com/?m=199911' title='November 1999'>November 1999</a></li>
		</ul>
</div></div>
</td>
<!-- / Right Sidebar -->
in this case we look for the Meta Widget and find id="meta". Now we have what we need.

go to ATO-> HTML/CSS Inserts -> CSS Inserts and add the following

HTML Code:
#body-page-NN #XXXXXX { display:none; }
where NN is the page number and XXXXXX is the id of the widget, so in this case it would be

HTML Code:
#body-page-2 #meta { display:none; }
and that should be it. Now whenever page 2 is viewed, the META widget won't be displayed.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Jun 1, 2009, 08:43 AM
d_random
 
51 posts · Apr 2009
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?
  #4  
Old Jun 1, 2009, 09:08 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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.
it will show you all the conditional tage WordPress supports.

I think the one you ate looking for is 'is_page('22')
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Last edited by juggledad; Jun 1, 2009 at 09:10 AM.
  #5  
Old Jun 1, 2009, 11:46 AM
d_random
 
51 posts · Apr 2009
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
  #6  
Old Jun 1, 2009, 01:43 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
is_page('22') = is page 22

!is_page('22') = is NOT ipage 22
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #7  
Old Jun 1, 2009, 02:46 PM
d_random
 
51 posts · Apr 2009
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?

Last edited by d_random; Jun 1, 2009 at 02:56 PM.
  #8  
Old Jun 2, 2009, 04:46 AM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
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
  #9  
Old Jun 2, 2009, 08:23 AM
d_random
 
51 posts · Apr 2009
Thanks Flynn!!!
This one worked.

!is_page('22') AND !is_home()

Bookmarks



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Probs w/tag line ariels Header configuration & styling 8 Jul 13, 2009 07:41 PM
[SOLVED] How To Create A Tag Cloud Page fromtheranks Atahualpa 3 Wordpress theme 2 Jun 23, 2009 04:26 PM
[SOLVED] Adding wp_footer before body tag Chester Post-Kicker, -Byline & -Footer 6 Jun 7, 2009 11:24 AM
How do I provide a conditional Widget in the sidebars? bgt Forum How-To 1 Jun 1, 2009 03:16 PM
How do I exclude Comments feed from Widget dave925 RSS, Feeds & Subscribing 2 Apr 6, 2009 08:42 PM


All times are GMT -6. The time now is 11:44 PM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.