• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Genesis, Adrotate plugin and Maxmind Geotracking

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Genesis, Adrotate plugin and Maxmind Geotracking

This topic is: resolved

Tagged: genesis, geotargeting, javascript, js, maxmind, php

  • This topic has 1 reply, 2 voices, and was last updated 12 years ago by cehwitham.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • April 30, 2013 at 12:51 pm #38609
    mathiasppc
    Member

    Hi there,

    Have spent many hours now on trying to figure out how I can get these three working together. Would really appreciate any input/suggestions on how to tackle this.

    I think it can be done with either JS or PHP, the last one would require an external plugin like Exec-PHP.

    First of all, from a performance standpoint, is it bad to run PHP code inside posts, widgets etc?

     

    Here`s what I`ve got so far in JS:

    <code>

    `
    if (country_code==’US’)
    {
    document.write("[adrotate banner="1"]");
    }
    else
    {
    document.write("[adrotate banner="2"]");
    }
    
     
    
    `
    The problem is that outputing the shortcodes does not work. I`ve tried all combinations of using ' and ", but no luck!
    
     
    
    I could use PHP too. In that case I`m having problems with saving the variable country_code globally. I want to only run the code before the if-statement once (and not for every ad on my page).
    
     
    
    <code>
    
    <?php
    require_once(“geoip.inc”);
    $gi = geoip_open(“GeoIP.dat”,GEOIP_STANDARD);
    $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
    geoip_close($gi);
    if($country_code == ‘US’ || $country_code == false)
    {
    echo adrotate_group(1);
    }
    else
    {
    echo adrotate_group(2);
    }
    ?>
    
    </code> 
    
     
    
    Again, would love any responses on this!
    
    Thanks in advance
    
     
    
    -Mathias
    
    http://energyinformative.org/genesis/
    June 2, 2013 at 5:41 pm #43711
    cehwitham
    Member

    Hi Mathias,

    I would write the PHP code into a function then use a genesis hook to inset it into the right place. genesis_before_post for example.

    Chris


    Twitter: cehwitham Web: cehwitham.com

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble