diff --git a/includes/sites.php b/includes/sites.php new file mode 100644 index 0000000..decdec4 --- /dev/null +++ b/includes/sites.php @@ -0,0 +1,51 @@ + 'site', + 'posts_per_page' => -1, // -1 for all posts + 'post_status' => 'publish', + 'orderby' => 'title', + 'order' => 'ASC' +); + +$query = new WP_Query( $options ) or die("WP Query failed"); + +$sites = array(); + +if ( $query->have_posts() ) : + while ( $query->have_posts() ) : $query->the_post() ; + $meta = get_post_meta( get_the_ID() ); + + // party_affiliation + // hyperlocal_group_id + + $row = array( + 'title' => get_the_title(), + 'url' => get_permalink(), + 'feed_url' => $meta['feed_url'][0], + 'date_created' => get_the_date("c"), + 'date_modified' => get_the_modified_date("c"), + 'lat' => (float)$meta['geo_latitude'][0], + 'lon' => (float)$meta['geo_longitude'][0], + 'radius_miles' => (float)$meta['distance_covered_miles'][0], + 'area_covered' => $meta['area_covered'][0], + 'body' => get_the_content(), + 'area_covered' => $meta['area_covered'][0], + 'country' => get_the_terms( get_the_ID(), 'countries' ), + 'council' => get_the_terms( get_the_ID(), 'councils' ), + 'platform' => get_the_terms( get_the_ID(), 'platforms' ), + ); + + $sites[]= $row; + endwhile; +else : + echo "No posts matched the query"; +endif; + +header( "Content-Type: application/json" ); +echo json_encode( $sites ); diff --git a/talhyperlocal.php b/talhyperlocal.php index b997235..6d79ba7 100644 --- a/talhyperlocal.php +++ b/talhyperlocal.php @@ -3,7 +3,7 @@ Plugin Name: Talk About Local Hyperlocal Sites Directory Plugin URI: Description: -Version: 0.1.1 +Version: 0.1.2.1 Author: Adrian Short Author URI: https://adrianshort.org/ License: GPL v3