Created
December 22, 2014 05:18
-
-
Save designbuildtest/fa5ede0aaae921b3b98e to your computer and use it in GitHub Desktop.
Testimonials
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onehundred_testimonials_register_post_type() { | |
| $args = array( | |
| 'labels' => array( | |
| 'name' => _x( 'Testimonials', 'post type general name', 'onehundred' ), | |
| 'singular_name' => _x( 'Testimonial', 'post type singular name', 'onehundred' ), | |
| 'add_new' => _x( 'Add New', 'location', 'onehundred' ), | |
| 'add_new_item' => __( 'Add Testimonial', 'onehundred' ), | |
| 'edit_item' => __( 'Edit Testimonial', 'onehundred' ), | |
| 'new_item' => __( 'New Testimonial', 'onehundred' ), | |
| 'all_items' => __( 'All Testimonials', 'onehundred' ), | |
| 'view_item' => __( 'View Testimonial', 'onehundred' ), | |
| 'search_items' => __( 'Search Testimonials', 'onehundred' ), | |
| 'not_found' => __( 'No testimonial found', 'onehundred' ), | |
| 'not_found_in_trash' => __( 'No testimonial in Trash', 'onehundred' ) | |
| ), | |
| 'public' => true, | |
| 'publicly_queryable' => true, | |
| 'exclude_from_search' => true, | |
| 'show_in_nav_menus' => true, | |
| 'show_in_menu' => true, | |
| 'show_in_admin_bar' => false, | |
| 'show_ui' => true, | |
| 'menu_icon' => 'dashicons-testimonial', | |
| 'has_archive' => 'testimonials', | |
| 'query_var' => 'testimonial', | |
| 'hierarchical' => false, | |
| 'capability_type' => 'page', | |
| 'supports' => array('title', 'editor', 'excerpt', 'page-attributes', 'thumbnail'), | |
| 'rewrite' => array('slug'=>'testimonials', 'with_front'=>false), | |
| ); | |
| $args = apply_filters('onehundred_testimonials_args', $args); // allow filtering | |
| register_post_type('testimonial', $args); | |
| } | |
| add_action('init', 'onehundred_testimonials_register_post_type'); | |
| function onehundred_testimonials_html($number) { | |
| if ( ! is_post_type_archive('testimonial') ) { | |
| $args = array( | |
| 'post_type' => 'testimonial', | |
| 'posts_per_page' => $number, | |
| 'orderby' => 'menu_order', | |
| 'order' => 'ASC', | |
| ); | |
| $loop = new WP_Query($args); | |
| if ( $loop->have_posts() ) : ?> | |
| <div class="testimonials-module"> | |
| <div class="container"> | |
| <div class="slider-testie"> | |
| <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> | |
| <blockquote> | |
| <?php the_excerpt(); ?> | |
| <footer><cite><?php the_title(); ?></cite></footer> | |
| </blockquote> | |
| <?php endwhile; ?> | |
| </div> | |
| </div> | |
| </div><?php | |
| endif; | |
| wp_reset_postdata(); | |
| } | |
| } | |
| function onehundred_testimonials_archive_query($query) { | |
| if ( $query->is_post_type_archive('testimonial') && $query->is_main_query() ) { | |
| $query->query_vars['posts_per_page'] = -1; // Show all Testimonials | |
| $query->query_vars['orderby'] = 'menu_order'; | |
| $query->query_vars['order'] = 'ASC'; | |
| } | |
| } | |
| add_action('pre_get_posts', 'onehundred_testimonials_archive_query'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment