_x( 'News & Updates', 'post type general name' ), 'singular_name' => _x( 'News & Update', 'post type singular name' ), 'add_new' => _x( 'Add New', 'News & Update' ), 'add_new_item' => __( 'Add New News & Update' ), 'edit_item' => __( 'Edit News & Update' ), 'new_item' => __( 'New News & Update' ), 'all_items' => __( 'All News & Update' ), 'view_item' => __( 'View News & Update' ), 'search_items' => __( 'Search News & Update' ), 'not_found' => __( 'No News & Update found' ), 'not_found_in_trash' => __( 'No News & Update found in the Trash' ), 'menu_name' => 'News & Updates' ); $args = array( 'labels' => $labels, 'description' => 'Holds our News & Update specific data', 'public' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-welcome-view-site', 'supports' => array( 'title', 'thumbnail', 'editor' ), 'has_archive' => true, ); register_post_type( 'news_updates', $args ); } add_action( 'init', 'wpclcl_news_list' ); //hook into the init action and call create_topics_nonhierarchical_taxonomy when it fires add_action( 'init', 'create_news_updates_taxonomy', 0 ); function create_news_updates_taxonomy() { // Labels part for the GUI $labels = array( 'name' => _x( 'Category', 'taxonomy general name' ), 'singular_name' => _x( 'Category', 'taxonomy singular name' ), 'search_items' => __( 'Search Category' ), 'popular_items' => __( 'Popular Category' ), 'all_items' => __( 'All Category' ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Edit Category' ), 'update_item' => __( 'Update Category' ), 'add_new_item' => __( 'Add New Category' ), 'new_item_name' => __( 'New Category Name' ), 'separate_items_with_commas' => __( 'Separate Category with commas' ), 'add_or_remove_items' => __( 'Add or remove Category' ), 'choose_from_most_used' => __( 'Choose from the most used Category' ), 'menu_name' => __( 'Category' ), ); // Now register the non-hierarchical taxonomy like tag register_taxonomy('news_category','news_updates',array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'rewrite' => array( 'slug' => 'categories' ), )); } // create shortcode to list all Testimonials which come in blue add_shortcode( 'allinone-news', 'wpclcl_news_query_list' ); function wpclcl_news_query_list( $atts ) { ob_start(); $query = new WP_Query( array( 'post_type' => 'news_updates', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'rand', ) ); if ( $query->have_posts() ) { ?>
No News are there.
'; } echo $args['after_widget']; } // Widget Backend public function form( $instance ) { if ( isset( $instance[ 'title' ] ) ) { $title = $instance[ 'title' ]; } else { $title = __( 'New title', 'wpb_widget_domain' ); } // Widget admin form ?>