Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This ishortcode will print different type of post [post_list type="post/page"]
- <?php
- /*
- Plugin Name: Stock Toolkit
- */
- //This is registration of custom post type
- add_action( 'init', 'rusho_custom_post' );
- function rusho_custom_post() {
- register_post_type( 'testimonial',
- array(
- 'labels' => array(
- 'name' => __( 'Testimonials' ),
- 'singular_name' => __( 'Testimonial' )
- ),
- 'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
- 'public' => false,
- 'show_ui' => true
- )
- );
- }
- function post_list_shortcode($atts){
- extract( shortcode_atts( array(
- 'count' => -1,
- 'type' => 'page',
- ), $atts) );
- $q = new WP_Query(
- array('posts_per_page' => $count,
- 'post_type' => $type
- )
- );
- $list = '<ul>';
- while($q->have_posts()) : $q->the_post();
- $idd = get_the_ID();
- $post_content = get_the_content();
- $list .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
- endwhile;
- $list.= '</ul>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('post_list', 'post_list_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement