not really known
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

53 строки
1.6 KiB

  1. <?php
  2. // ini_set( 'display_errors', 1 );
  3. // error_reporting( E_ALL ^ E_NOTICE );
  4. define( 'WP_USE_THEMES', false );
  5. require_once( '../../../../wp-load.php' );
  6. $options = array(
  7. 'post_type' => 'site',
  8. 'posts_per_page' => -1, // -1 for all posts
  9. 'post_status' => 'publish',
  10. 'orderby' => 'title',
  11. 'order' => 'ASC'
  12. );
  13. $query = new WP_Query( $options ) or die("WP Query failed");
  14. $sites = array();
  15. if ( $query->have_posts() ) :
  16. while ( $query->have_posts() ) : $query->the_post() ;
  17. $meta = get_post_meta( get_the_ID() );
  18. // party_affiliation
  19. // hyperlocal_group_id
  20. $row = array(
  21. 'title' => get_the_title(),
  22. 'url' => get_permalink(),
  23. 'feed_url' => $meta['feed_url'][0],
  24. 'date_created' => get_the_date("c"),
  25. 'date_modified' => get_the_modified_date("c"),
  26. 'lat' => (float)$meta['geo_latitude'][0],
  27. 'lon' => (float)$meta['geo_longitude'][0],
  28. 'radius_miles' => (float)$meta['distance_covered_miles'][0],
  29. 'area_covered' => $meta['area_covered'][0],
  30. 'body' => get_the_content(),
  31. 'area_covered' => $meta['area_covered'][0],
  32. 'country' => get_the_terms( get_the_ID(), 'countries' ),
  33. 'council' => get_the_terms( get_the_ID(), 'councils' ),
  34. 'platform' => get_the_terms( get_the_ID(), 'platforms' ),
  35. 'group' => get_the_terms( get_the_ID(), 'groups' )
  36. );
  37. $sites[]= $row;
  38. endwhile;
  39. else :
  40. echo "No posts matched the query";
  41. endif;
  42. header( "Content-Type: application/json" );
  43. echo json_encode( $sites );