Changeset 1558498
- Timestamp:
- 12/20/2016 05:35:16 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
all-in-one-news-scroll/trunk/allinone-news-scroll.php
r1396998 r1558498 31 31 'public' => true, 32 32 'menu_position' => 5, 33 'menu_icon'=> 'dashicons-welcome-view-site',33 'menu_icon' => 'dashicons-welcome-view-site', 34 34 'supports' => array( 'title', 'thumbnail', 'editor' ), 35 35 'has_archive' => true, … … 38 38 } 39 39 add_action( 'init', 'wpclcl_news_list' ); 40 41 //hook into the init action and call create_topics_nonhierarchical_taxonomy when it fires 42 43 add_action( 'init', 'create_news_updates_taxonomy', 0 ); 44 45 function create_news_updates_taxonomy() { 46 47 // Labels part for the GUI 48 49 $labels = array( 50 'name' => _x( 'Category', 'taxonomy general name' ), 51 'singular_name' => _x( 'Category', 'taxonomy singular name' ), 52 'search_items' => __( 'Search Category' ), 53 'popular_items' => __( 'Popular Category' ), 54 'all_items' => __( 'All Category' ), 55 'parent_item' => null, 56 'parent_item_colon' => null, 57 'edit_item' => __( 'Edit Category' ), 58 'update_item' => __( 'Update Category' ), 59 'add_new_item' => __( 'Add New Category' ), 60 'new_item_name' => __( 'New Category Name' ), 61 'separate_items_with_commas' => __( 'Separate Category with commas' ), 62 'add_or_remove_items' => __( 'Add or remove Category' ), 63 'choose_from_most_used' => __( 'Choose from the most used Category' ), 64 'menu_name' => __( 'Category' ), 65 ); 66 67 // Now register the non-hierarchical taxonomy like tag 68 69 register_taxonomy('news_category','news_updates',array( 70 'hierarchical' => true, 71 'labels' => $labels, 72 'show_ui' => true, 73 'show_admin_column' => true, 74 'update_count_callback' => '_update_post_term_count', 75 'query_var' => true, 76 'rewrite' => array( 'slug' => 'categories' ), 77 )); 78 } 79 40 80 41 81 // create shortcode to list all Testimonials which come in blue … … 47 87 'posts_per_page' => -1, 48 88 'order' => 'ASC', 49 'orderby' => ' title',89 'orderby' => 'rand', 50 90 ) ); 51 91 if ( $query->have_posts() ) { ?> … … 69 109 } 70 110 } 111 // create shortcode to list all Testimonials which come in blue 112 add_shortcode( 'allinone-news-category', 'wpclcl_news_query_list_category' ); 113 function wpclcl_news_query_list_category( $atts ) { 114 ob_start(); 115 116 // define attributes and their defaults 117 extract( shortcode_atts( array ( 118 'type' => 'news_updates', 119 'order' => 'date', 120 'orderby' => 'rand', 121 'posts' => -1, 122 'category' => '', 123 ), $atts ) ); 124 125 $query = new WP_Query( array( 126 'post_type' => 'news_updates', 127 'posts_per_page' => -1, 128 'order' => $order, 129 'orderby' => $orderby, 130 'news_category' => $category, 131 ) ); 132 if ( $query->have_posts() ) { ?> 133 <div class="vticker"> 134 <ul> 135 <?php while ( $query->have_posts() ) : $query->the_post(); ?> 136 <li class="item-event" id="post-<?php the_ID(); ?>"> 137 <div class="news-event"> 138 <div class="news_title"> 139 <h3><?php the_title(); ?></h3> 140 <p><?php the_content(); ?></p> 141 </div> 142 </div> 143 </li> 144 <?php endwhile; 145 wp_reset_postdata(); ?> 146 </ul> 147 </div> 148 <?php $myvariable_news1 = ob_get_clean(); 149 return $myvariable_news1; 150 } 151 } 71 152 72 153
Note: See TracChangeset
for help on using the changeset viewer.