WordPress.org

Ready to get started?Download WordPress

Forums

Displaying different images for different IPs (4 posts)

  1. Jon W
    Member
    Posted 8 months ago #

    Is it possible to do this within a Post or Page, without making custom templates for each individual one?

    Ideally a way to wrap some code around that links to a maxmind type of database for the IP part.

    Needs to be simple, like me.

    Thanks.

  2. Keith Driscoll
    Member
    Posted 8 months ago #

    Depends how you define simple :)

    It can surely be done with some PHP code http://us2.php.net/manual/en/book.geoip.php

    I don't know of a plugin :( but it sounds like you are looking for a way to serve geo based images.

  3. Oizuled
    Member
    Posted 8 months ago #

    I'm assuming you want to display something like a flag for each specific country?
    You can find info about how to do this here
    Real quick code to use in a page template (just one template should dynamically generate the correct flag code for each country), might look like:

    <?php
    $ip = $_SERVER['REMOTE_ADDR'];
    ?>
    <img src='http://api.hostip.info/flag.php?ip=<?php echo $ip; ?>' alt='IP Address Lookup' />
  4. Jon W
    Member
    Posted 8 months ago #

    Not sure if page templates will work for me. The image is within the body of the post.

    Will see if I can get php working in Pages and try the second option.

    Not flags, just pictures / photos that are specific to particular locations.

Reply

You must log in to post.

About this Topic