Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. IN FUNCTIONS.PHP or best way in (IN FUNCTIONS.PHP includes) include/custom-post-type.php
  2.  
  3. OR USE PLUGIN wp cpt ui - not reliably
  4.  
  5. (IMPORTANT TO WRITE VALUE TRUE IN custom post == 'has_archive' => true, == if you need custom post type archive page
  6.  
  7. <?php
  8. /**
  9. * Create custom post types.
  10. */
  11. add_action('init', 'create_posttype');
  12.  
  13. function create_posttype()
  14. {
  15. register_post_type('testimonials',
  16. array(
  17. 'supports' => array('title', 'editor'),
  18. 'labels' => array(
  19. 'name' => __('Testimonials'),
  20. 'singular_name' => __('Testimonial')
  21. ),
  22. 'public' => true,
  23. 'menu_position' => 5,
  24. 'menu_icon' => 'dashicons-format-quote',
  25. 'rewrite' => array('slug' => 'testimonials'),
  26. )
  27. );
  28. register_post_type('logo',
  29. array(
  30. 'supports' => array('title', 'editor'),
  31. 'labels' => array(
  32. 'name' => __('Logo'),
  33. 'singular_name' => __('Logo')
  34. ),
  35. 'public' => true,
  36. 'menu_position' => 6,
  37. 'menu_icon' => 'dashicons-images-alt2',
  38. 'rewrite' => array('slug' => 'logo'),
  39. )
  40. );
  41.  
  42. register_post_type('blog',
  43. array(
  44. 'supports' => array(
  45. 'title',
  46. 'editor',
  47. 'custom-fields',
  48. 'revisions',
  49. 'page-attributes',
  50. 'thumbnail'
  51. ),
  52. 'labels' => array(
  53. 'name' => __('Blog'),
  54. 'singular_name' => __('Blog')
  55. ),
  56. 'public' => true,
  57. 'menu_position' => 3,
  58. 'menu_icon' => 'dashicons-book',
  59. 'has_archive' => true,
  60. 'rewrite' => array(
  61. 'slug' => 'blog',
  62. 'with_front' => false
  63. ),
  64. )
  65. );
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement