Have you ever wanted to display different ADS at the same spot on a sidebar in different categories and wondered how to do it on your wordpress blog, well, here is your solution.
For instance, let’s say you run Adsense on your blog sidebar, you were then paid by an advert client to display their ADs only on your blogging category alone with URL

http://www.yoursite.com/category/blogging

And Adsense only on that same spot on other pages and posts. Here is how it’s done.

how to WP Logic WordPress Plugin

Displaying Different Adverts at the same spot using Wp-Login

Here is how to achieve the example we discussed above.

  • Login to your WordPress Dashboard.
  • Install Wp Logic Plugin, then Activate the Plugin.Read: Guide on How to Install A WordPress Plugin
  • Add two Widgets to your WordPress Sidebar, One with the Adsense and the Second with the custom Advert.
  • Below each of the Widget, you will see a box with Widget Logic Title. Now in those boxes you have to input some tags.
  • You need to get the category ID for the Blogging category you wish to display a custom AD.
    Read: How to find a Category ID in WordPress.Now for the adsense widget logic box, input

    !is_category( '9' )
    While in the Custom Ad Widget, in the Logic box input this

    is_category( '9' )

    We are assuming that 9 is the Category ID, then Save them.
  • The custom Ad would display only on that category alone, while the Adsense would Display Else where.

Here are Some other Conditional Tag you need to know about WP Logic Plugin.

 

The Conditions For …

All of the Conditional Tags test to see whether a certain condition is met, and then returns either TRUE or FALSE. The conditions under which various tags output TRUE is listed below. Those tags which can accept parameters are so noted.

The Main Page

is_home() 
When the main blog page is being displayed. This is the page which shows the time based blog content of your site, so if you’ve set a static Page for the Front Page (see below), then this will only be true on the Page which you set as the “Posts page” inAdministration > Settings > Reading.

The Front Page

is_front_page() 
When the front of the site is displayed, whether it is posts or a Page. Returns true when the main blog page is being displayed and the ‘Settings > Reading ->Front page displays’ is set to “Your latest posts”, or when ‘Settings > Reading ->Front page displays’ is set to “A static page” and the “Front Page” value is the current Page being displayed.

The Administration Panels

is_admin()
When the Dashboard or the administration panels are being displayed.

A Single Post Page

is_single() 
When any single Post (or attachment, or custom Post Type) page is being displayed. (False for Pages)
is_single( ’17’ ) 
When Post 17 is being displayed as a single Post.
is_single( ‘Irish Stew’ ) 
When the Post with Title “Irish Stew” is being displayed as a single Post.
is_single( ‘beef-stew’ ) 
When the Post with Post Slug “beef-stew” is being displayed as a single Post.
is_single( array( 17, ‘beef-stew’, ‘Irish Stew’ ) ) 
Returns true when the single post being displayed is either post ID 17, or the post_nameis “beef-stew”, or the post_title is “Irish Stew”.
is_single( array( 17, 19, 1, 11 ) ) 
Returns true when the single post being displayed is either post ID = 17, post ID = 19, post ID = 1 or post ID = 11.
is_single( array( ‘beef-stew’, ‘pea-soup’, ‘chili’ ) ) 
Returns true when the single post being displayed is either the post_name “beef-stew”, post_name “pea-soup” or post_name“chili”.
is_single( array( ‘Beef Stew’, ‘Pea Soup’, ‘Chili’ ) ) 
Returns true when the single post being displayed is either the post_title is “Beef Stew”, post_title is “Pea Soup” or post_title is “Chili”.

Note: This function does not distinguish between the post ID, post title, or post name. A post named “17” would be displayed if a post ID of 17 was requested. Presumably the same holds for a post with the slug “17”.

A Sticky Post

is_sticky() 
Returns true if “Stick this post to the front page” check box has been checked for the current post. In this example, no post ID argument is given, so the post ID for the Loop post is used.
is_sticky( ’17’ ) 
Returns true when Post 17 is considered a sticky post.

A Post Type

get_post_type() 
Not really a conditional tag, but returns the registered post type of the current post.
if ( ‘book’ == get_post_type() ) … 
Tests to see if the current post is of type ‘book’.
is_singular()
Returns true for any is_singular, is_page, and is_attachment. It does allow testing for post types.
post_type_exists() 
Returns true if a given post type is a registered post type. This does not test if a post is a certain post_type. Note: This function replaces a function called is_post_type which existed briefly in 3.0 development.

A Post Type is Hierarchical

is_post_type_hierarchical( $post_type ) 
Returns true if this $post_type has been set with hierarchical support when registered.
is_post_type_hierarchical( ‘book’ ) 
Returns true if the book post type was registered as having support for hierarchical.

A Post Type Archive

is_post_type_archive() : Returns true on any post type archive.
is_post_type_archive( $post_type ) : Returns true if on a post type archive page that matches $post_type (can be a single post type or an array of post types).

To turn on post type archives, use ‘has_archive’ => true, when registering the post type.

A Comments Popup

is_comments_popup() 
When in Comments Popup window.

Any Page Containing Posts

comments_open()
When comments are allowed for the current Post being processed in the WordPress Loop.
pings_open()
When pings are allowed for the current Post being processed in the WordPress Loop.

A PAGE Page

This section refers to WordPress Pages, not any generic webpage from your blog, or in other words to the built in post_type ‘page’.

is_page() 
When any Page is being displayed.
is_page( 42 ) 
When Page 42 (ID) is being displayed.
is_page( ‘About Me And Joe’ ) 
When the Page with a post_title of “About Me And Joe” is being displayed.
is_page( ‘about-me’ ) 
When the Page with a post_name (slug) of “about-me” is being displayed.
is_page( array( 42, ‘about-me’, ‘About Me And Joe’ ) ) 
Returns true when the Pages displayed is either post ID = 42, or post_name is “about-me”, or post_title is “About Me And Joe”.
is_page( array( 42, 54, 6 ) ) 
Returns true when the Pages displayed is either post ID = 42, or post ID = 54, or post ID = 6.

Testing for paginated Pages

You can use this code to check whether you’re on the nth page in a Post or PAGE Page that has been divided into pages using the<!–nextpage–> QuickTag. This can be useful, for example, if you wish to display meta-data only on the first page of a post divided into several pages.

Reference: The Conditional Tags were sourced from WordPress Conditional Tags

I hope this helped.

LEAVE A REPLY

Please enter your comment!
Please enter your name here