1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anyway to do this in Wordpress?

Discussion in 'Black Hat SEO' started by smartalex4, Jan 2, 2011.

  1. smartalex4

    smartalex4 Junior Member

    Joined:
    Jun 5, 2009
    Messages:
    163
    Likes Received:
    57
    I would like to know if there is a way to add Ads based on categories?

    For example, is there a way I could add Chicago specific ads to all my post that to pertain to Chicago, and New York specific ads to the New York post...etc....without having to go into each post one by one?

    Thanks in advance
     
  2. antsaoo

    antsaoo Supreme Member

    Joined:
    Oct 1, 2008
    Messages:
    1,292
    Likes Received:
    637
    There probably are some plugins which can do this. i suggest searching for such plugin :)
     
  3. smartalex4

    smartalex4 Junior Member

    Joined:
    Jun 5, 2009
    Messages:
    163
    Likes Received:
    57
    I've been searchin' but so far...no dice.
     
  4. razohad

    razohad Power Member

    Joined:
    Jan 11, 2008
    Messages:
    701
    Likes Received:
    1,005
    Occupation:
    Software engginer
    Location:
    online most of the time
    if your ads are in widgets the you can install the widget-logic plugin and then you can control
    were to display witch ad and you can do that like that:

    for example say your Chicago category id is 25 the just add
    PHP:
    is_category(25)
    to the Chicago ads widget
    and it will only show on that category
    the same goes for any other category you want.

    if your add are not widgets the you can use this conditional function in your theme files
    like this
    PHP:
    if(is_category(25)){
    //display Chicago adds here
    }
    else{
    //other ads
     
    • Thanks Thanks x 1
  5. sirgold

    sirgold Supreme Member

    Joined:
    Jun 25, 2010
    Messages:
    1,260
    Likes Received:
    646
    Occupation:
    Busy proving the Pareto principle right
    Location:
    A hot one
    CLIENT SIDE

    Add the js as described here to your WP: http://www.maxmind.com/app/javascript_city

    Make a simple check in javascript on the city and write your ad accordingly.

    SERVER SIDE

    If you feel like using php you can use this simple snippet AFTER downloading the proper huge library from: http://www.maxmind.com/app/geolitecity (the php version, of course...). Edit the code below and put it in the WP template wherever it needs to show up. This just prints the name of the city.. Add your own checks to it and "echo" what needs to be displayed accordingly

    The folloiwing SUUUUPER-simple code assumes you uploaded geoipcity.inc, geoipregionvars.php and the dat file in the home dir of your webserver. Enjoy!

    Code:
    <?php
    ///////////////////////////////////////////////////////////////////////////////
    // This code demonstrates how to lookup the country, region, city, postal code, 
    // latitude, and longitude by IP. Designed to work with GeoIP/GeoLite City
    // Note that you must download the New Format of GeoIP City (GEO-133). 
    // The old format (GEO-132) will not work.
    // 
    // Based on sample_city.php enriched by a genius
    ///////////////////////////////////////////////////////////////////////////////
    include("geoipcity.inc");
    include("geoipregionvars.php");
    
    $gi = geoip_open($_SERVER['DOCUMENT_ROOT'] . "/GeoLiteCity.dat",GEOIP_STANDARD);
    $record = geoip_record_by_addr($gi,$_SERVER['REMOTE_ADDR']);
    
    echo $record->city; // Your Checks Abt The City Here...
    ?>
    
     
    • Thanks Thanks x 1