Solved

Need guidance to build a post list directory

Posted on 2014-01-07
7
340 Views
Last Modified: 2014-01-07
Dear experts,

I am trying to add to a wordpress site a list of places around a downtown. It is pretty local, and only one person is going to be in charge of adding places. the outcome would be something like this:

Place1 name
Description
Address
Website
More info

Place2 name
Description
Address
Website
More info

I was thinking in using wordpress Business Directory but unfortunately it displays each post on the base page where your short-code is placed. I need each post to be placed on its own page, and it seems that is not possible according to this thread http://wordpress.org/support/topic/why-does-the-single-view-stay-on-the-main-page-it-should-be-its-own-post?replies=7#post-5078193


Since this is not a paid business directory and only one person is going to upload content, I was thinking to do that directory list using posts, categories and an alphabetical search plugin.

To create each entry for each business I was thinking to use custom fields to add the address, description etc. So far I think I am fine.


The problem that I am facing is that I  need to display a main map to locate all the business in the site. At this point I am stuck.  Could someone please give me an advice?

Thank you very much,

Winter
0
Comment
Question by:glepiza
7 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39762832
It wouldn't take much php coding to pull all the addresses using a query that filters out the relevant posts. Then you could use Google Maps API to geocode the addresses onto a Google map.
0
 
LVL 9

Assisted Solution

by:Rowby Goren
Rowby Goren earned 100 total points
ID: 39762892
Hello Winter,

Awhile back someone wanted me to do a Wordpress business directory.  Here are a few that I found.  I didn't build the site so I have no hands-on experience with these recommendations.  

But check them out:   Vantage has a big map on the home page.

http://demos.appthemes.com/?theme=vantage
http://wordpress.org/plugins/business-directory-plugin/

Keep in mind that the above example can be modified -- the various widgets can be turned on or off.

Rowby
0
 
LVL 32

Assisted Solution

by:DrDamnit
DrDamnit earned 100 total points
ID: 39762937
If you are manually uploading content to these pages, I don't see why you don't just embed a map manually as well:

https://support.google.com/maps/answer/72644?hl=en

It seems to me that it would be more work to separate these out into fields to the point where a plugin would be able to read them than to just copy / paste the embed code.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:glepiza
ID: 39763366
Hello guys, thank you for your answers.

Just for clarification, attached goes an image of what I am trying to accomplish.
As you can say, there is just a main map that places all the Addresses that are inserted into the form for each post.
Hi, Dr Damnit, I did not understand exactly your answer. The thing is that I don´t need just to embed a map with a single direction, I need to embed a single map that localize all the addresses inserted into the post.

I guess a need a google map custom field or something… but how can I retrieve that data to place it on the map….

thank you guys, I would appreciate if you can please give me more suggestions :)
list.jpg
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 300 total points
ID: 39763522
This is what I'm suggesting. The page that displays the map and list will be a custom Wordpress page template. In that template php file you could do something like this to collect the meta data created by the custom fields.
<?php

$addresses = array(); //array to hold addresses
// get categories of locations. Gets all children of parent category "Locations" ex. "Companies", "Restuarants", etc.
$cat_title = $wpdb->get_results("SELECT t0.term_id, t0.name FROM wp_terms AS t0 INNER JOIN (SELECT t1.term_id FROM wp_term_taxonomy AS t1 WHERE t1.parent = (SELECT t3.term_id FROM wp_terms AS t3 WHERE t3.name='Locations')) AS t2 ON t2.term_id=t0.term_id");

//loop through the categories
foreach ($cat_title as $cat) {
	//find all posts associated with the current category
	$posts = $wpdb->get_results("SELECT t1.ID FROM wp_posts AS t1 INNER JOIN wp_term_relationships AS t2 ON t2.object_id = t1.ID WHERE (t1.post_status = 'Publish' OR t1.post_status = 'Private') AND t2.term_taxonomy_id = $cat->term_id ORDER BY t1.post_date ASC");
	
	//loop through the posts to get the metadata
	foreach ($posts as $post) {
		$this_meta = get_post_meta($post->ID);
		// at this point you could capture all metadata for a given post and echo to the page
		// or just push the addresses to an array and echo that for Google Maps API to Geocode onto a map
                foreach ($this_meta as $meta) {
	               if ($meta->meta_key === "Address") {
		    	     array_push($addresses, $meta->meta_key);
		       }
		}  
	}
}

?>

Open in new window

Once you have an array of addresses on the page you can use the Google Maps API to Geocode the markers for you. Many examples of how to do that online. Here is one of my own examples from another EE post:

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28161118.html
0
 

Author Comment

by:glepiza
ID: 39763969
Hi Tom,

Thank you very much for helping me on this. I am going to give it try.  I am still learning to code for wordpress, so it might take me a while to get it lol. I just have two weeks to finish up the entire site and I am just so stuck on the directory part.

Thank you very much,

Winter
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39763979
You're welcome. Just ask new questions if you get stuck.

Thanks for the points.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What's this? As a volunteer Page Editor for Experts-Exchange.com, I have noticed that many authors also have blogs, and pull articles from their blogs to post at Experts-Exchange. I appreciate each author sharing their blog content with our site …
This article will shed light on the latest trends when it comes to your resume building needs. For far too long, the traditional CV format has monopolized the recruitment market.
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now