w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Wordpress: Assign Blog Posts to Locations for Location-Based Blog Archive Landing Pages

My initial thought on this would be to use a custom Taxonomy for your blog posts. They function just like Categories (can have archive pages, posts can have multiple taxonomies assigned, etc). We generally use the plugin, Types - Complete Solution for Custom Fields and Types, to manage our Taxonomies. (wordpress.org/plugins/types) If you are already familiar with working with Categories and their archive pages, it's not much different to work with Taxonomies.

The interface works with a checkbox list just like Categories. You set a name, slug, and optional description in the admin side of things. You then assign any number of Taxonomy terms to an individual post. Taxonomies, just like Categories, are just alternate ways to categorize posts. You can use the built-in archive file formats (taxonomy-{taxonomy_name}.php or taxonomy-{taxonomy_name}-{taxonomy_term_slug}.php) to built your template files. So if you had a taxonomy with the slug "locations" and your looking at posts with the term "nort_pole" you could make taxonomy-locations.php or taxonomy-locations-north_pole.php to serve as your templates for the archive pages. You can also use custom wp_queries to sort/filter your posts based on what taxonomy terms are applied to the posts you're looking for.

Here is a good article in the Wordpress Codex that talks about Taxonomies. http://codex.wordpress.org/Taxonomies

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.