Guest User

Untitled

a guest
Apr 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. function cptui_register_my_cpts_blog() {
  2.  
  3. /**
  4. * Post Type: Blog.
  5. */
  6.  
  7. $labels = array(
  8. "name" => __( "Blog", "testsite" ),
  9. "singular_name" => __( "Blog Post", "testsite" ),
  10. );
  11.  
  12. $args = array(
  13. "label" => __( "Blog", "testsite" ),
  14. "labels" => $labels,
  15. "description" => "",
  16. "public" => true,
  17. "publicly_queryable" => true,
  18. "show_ui" => true,
  19. "show_in_rest" => false,
  20. "rest_base" => "",
  21. "has_archive" => true,
  22. "show_in_menu" => true,
  23. "exclude_from_search" => false,
  24. "capability_type" => "post",
  25. "map_meta_cap" => true,
  26. "hierarchical" => false,
  27. "rewrite" => array( "slug" => "blog", "with_front" => true ),
  28. "query_var" => true,
  29. "menu_icon" => "dashicons-media-document",
  30. "supports" => array( "title", "revisions" ),
  31. );
  32.  
  33. register_post_type( "blog", $args );
  34. }
  35.  
  36. add_action( 'init', 'cptui_register_my_cpts_blog' );
  37.  
  38. function cptui_register_my_taxes_blog_types() {
  39.  
  40. /**
  41. * Taxonomy: Blog Types.
  42. */
  43.  
  44. $labels = array(
  45. "name" => __( "Blog Types", "testsite" ),
  46. "singular_name" => __( "Blog Type", "testsite" ),
  47. "menu_name" => __( "Update Blog Types", "testsite" ),
  48. );
  49.  
  50. $args = array(
  51. "label" => __( "Blog Types", "testsite" ),
  52. "labels" => $labels,
  53. "public" => true,
  54. "hierarchical" => false,
  55. "label" => "Blog Types",
  56. "show_ui" => true,
  57. "show_in_menu" => true,
  58. "show_in_nav_menus" => false,
  59. "query_var" => true,
  60. "rewrite" => array( 'slug' => 'blog_types', 'with_front' => true, ),
  61. "show_admin_column" => false,
  62. "show_in_rest" => false,
  63. "rest_base" => "",
  64. "show_in_quick_edit" => false,
  65. );
  66. register_taxonomy( "blog_types", array( "blog" ), $args );
  67. }
  68.  
  69. add_action( 'init', 'cptui_register_my_taxes_blog_types' );
  70.  
  71. $args = array(
  72. 'post_type' => 'blog',
  73. 'posts_per_page' => -1,
  74. 'tax_query' => array(
  75. array(
  76. 'taxonomy' => 'blog_types',
  77. 'field' => 'slug',
  78. 'terms' => 'tips',
  79. ),
  80. ),
  81. );
  82.  
  83. // Custom query.
  84. $query = new WP_Query( $args );
Add Comment
Please, Sign In to add comment