mrowinski Posted May 6, 2011 Share Posted May 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/235737-wordpress-and-geo/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.