Guest User

Untitled

a guest
Sep 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. register_post_type('queries', array(
  2. 'labels' => array(
  3. 'name' => 'Запросы', // Основное название типа записи
  4. 'singular_name' => 'Запрос', // отдельное название записи типа Book
  5. 'add_new' => 'Добавить запрос',
  6. 'add_new_item' => 'Добавление запроса',
  7. 'edit_item' => 'Редактировать запроса',
  8. 'new_item' => 'Новый запрос',
  9. 'view_item' => 'Посмотреть запрос',
  10. 'search_items' => 'Найти запрос',
  11. 'not_found' => 'Запрос не найдено',
  12. 'not_found_in_trash' => 'В корзине запросов не найдено',
  13. 'parent_item_colon' => '',
  14. 'menu_name' => 'Запросы'
  15.  
  16. ),
  17. 'public' => true,
  18. 'publicly_queryable' => true,
  19. 'show_ui' => true,
  20. 'show_in_menu' => true,
  21. 'query_var' => true,
  22. 'rewrite' => true,
  23. 'capability_type' => 'post',
  24. 'has_archive' => true,
  25. 'hierarchical' => false,
  26. 'menu_position' => null,
  27. 'supports' => array('title','editor','author','thumbnail','excerpt','comments')
  28. ) );
  29.  
  30. }
  31.  
  32.  
  33.  
  34. function getQueries(){
  35. $args = array(
  36. 'orderby' => 'date',
  37. 'order' => 'ASC',
  38. 'post_type' => 'queries',
  39. 'posts_per_page' => '8'
  40. );
  41.  
  42. $queries = [];
  43.  
  44. foreach (get_posts($args) as $post) {
  45. $query = get_fields($post->ID);
  46. $query['text'] = $post->post_content;
  47. $query['title'] = $post->post_title;
  48. $query['img'] = get_the_post_thumbnail_url($post->ID, 'thumbnail');
  49. $review['author'] = get_the_author();
  50. $queries[] = $query;
  51. }
  52.  
  53. return $queries;
  54. }
Add Comment
Please, Sign In to add comment