NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. function default_post_format( $item ) {
  3. $filtered = array();
  4. $filtered[id] = $item->ID;
  5. $filtered[slug] = $item->post_name;
  6. $filtered[type] = $item->post_type;
  7. $filtered[title] = $item->post_title;
  8. $filtered[excerpt] = $item->post_excerpt;
  9. $filtered[date] = $item->post_date;
  10. $filtered[content] = $item->post_content;
  11. $filtered[hero] = get_post_meta( $item->ID, 'hero_header', true );
  12. if($item->post_type === 'artist') {
  13. $filtered[sortname] = get_post_meta( $item->ID, 'artist-sort-name', true );
  14. $material_slugs = [];
  15. foreach (get_the_terms( $item, 'material' ) as $material_slug):
  16. array_push($material_slugs, $material_slug->slug);
  17. endforeach;
  18. $filtered[materials] = $material_slugs;
  19. }
  20. // Parse category IDs and store just the slugs
  21. $category_slugs = [];
  22. foreach (wp_get_post_categories( $item->ID ) as $id):
  23. $category = get_category($id);
  24. array_push($category_slugs, $category->slug);
  25. endforeach;
  26. $filtered[categories] = $category_slugs;
  27. return $filtered;
  28. }
  29. ?>