Solved

Need guidance to build a post list directory

Posted on 2014-01-07
7
349 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Transferring a wordpress site from a host or local dev server to another host can be a pain. So I've included my steps on how I have accomplished this task. Steps include an assumption that you have Cpanel access or Ftp access.. If you do not hav…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The purpose of this video is to demonstrate how to Import and export files in WordPress. 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 : Click on Too…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

792 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