Jump to content

Recommended Posts

I am using geoplugin on a simple wordpress blog and I display the visitors CITY and STATE on it. That part is easy and even I figured it out.

 

I also understand how to query any of my posts by TAG name, I tag my posts with the city and state that I visit.

 

What I am trying to do is simple, when a visitor is on my site, pull their city and state and query my posts to display those to him 1st, so that he/she can see a post related to his city when i visited there.

 

Here are a couple lines of code:

the geoplugin code to display the city and state:

//require_once('geoplugin.class.php');

//$geoplugin = new geoPlugin();

//$geoplugin->locate();

//echo "{$geoplugin->city} {$geoplugin->region}"

 

Here is the simple query:

//query_posts('tag=THIS IS WHERE I NEED THE CITY AND STATE');

//while ( have_posts() ) : the_post();

// echo '<li>';

// the_title();

// echo '</li>';

//endwhile;

 

// Reset Query

//wp_reset_query();

 

in the query you will see "THIS IS WHERE I NEED THE CITY AND STATE" that is where I need to plugin the visitors city and state, I also need to place a '-' in place of a space ' ' so I need to use a code like str_replace(' ', '-', or something since the TAG in wordpress can not have spaces and there are cities that have more then 1 word and then the state.

 

Any help? Any ideas?

 

Thanks guys

 

Martin

Link to comment
https://forums.phpfreaks.com/topic/235737-wordpress-and-geo/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.