WordPress.org

Support

Support » How-To and Troubleshooting » Displaying different images for different IPs

Displaying different images for different IPs

  • Jon

    @jonpaulwade

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Keith Driscoll

    @keithdriscoll

    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.

    Scott DeLuzio

    @scottdeluzio

    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' />

    Jon

    @jonpaulwade

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Displaying different images for different IPs’ is closed to new replies.
Skip to toolbar