Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cptui_register_my_cpts_blog() {
- /**
- * Post Type: Blog.
- */
- $labels = array(
- "name" => __( "Blog", "testsite" ),
- "singular_name" => __( "Blog Post", "testsite" ),
- );
- $args = array(
- "label" => __( "Blog", "testsite" ),
- "labels" => $labels,
- "description" => "",
- "public" => true,
- "publicly_queryable" => true,
- "show_ui" => true,
- "show_in_rest" => false,
- "rest_base" => "",
- "has_archive" => true,
- "show_in_menu" => true,
- "exclude_from_search" => false,
- "capability_type" => "post",
- "map_meta_cap" => true,
- "hierarchical" => false,
- "rewrite" => array( "slug" => "blog", "with_front" => true ),
- "query_var" => true,
- "menu_icon" => "dashicons-media-document",
- "supports" => array( "title", "revisions" ),
- );
- register_post_type( "blog", $args );
- }
- add_action( 'init', 'cptui_register_my_cpts_blog' );
- function cptui_register_my_taxes_blog_types() {
- /**
- * Taxonomy: Blog Types.
- */
- $labels = array(
- "name" => __( "Blog Types", "testsite" ),
- "singular_name" => __( "Blog Type", "testsite" ),
- "menu_name" => __( "Update Blog Types", "testsite" ),
- );
- $args = array(
- "label" => __( "Blog Types", "testsite" ),
- "labels" => $labels,
- "public" => true,
- "hierarchical" => false,
- "label" => "Blog Types",
- "show_ui" => true,
- "show_in_menu" => true,
- "show_in_nav_menus" => false,
- "query_var" => true,
- "rewrite" => array( 'slug' => 'blog_types', 'with_front' => true, ),
- "show_admin_column" => false,
- "show_in_rest" => false,
- "rest_base" => "",
- "show_in_quick_edit" => false,
- );
- register_taxonomy( "blog_types", array( "blog" ), $args );
- }
- add_action( 'init', 'cptui_register_my_taxes_blog_types' );
- $args = array(
- 'post_type' => 'blog',
- 'posts_per_page' => -1,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'blog_types',
- 'field' => 'slug',
- 'terms' => 'tips',
- ),
- ),
- );
- // Custom query.
- $query = new WP_Query( $args );
Add Comment
Please, Sign In to add comment