Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Promo Shortcode
- function recent_post_shortcode($atts){
- extract(shortcode_atts(array(
- 'posts' =>4,
- ), $atts));
- $return_string = ''; // wrapper will go here start
- query_posts(array('post_type'=>'frost_promo','posts_per_page'=>4,'order' => 'ASC','showposts' => $posts));
- if (have_posts()) :
- while (have_posts()) : the_post();
- $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'promo');
- $return_string .= '<div class="promo_option_promo text-center" style="width:270px;float:left;">
- <img src="'.$image[0].'" alt="'.get_the_title().'" />
- <h2 class="text-uppercase">'.get_the_title().'</h2>
- <p>'.get_the_content().'</p>
- </div>';
- endwhile;
- else: // if no post found the above then show here default data
- $return_string .='<div class="error-not-found text-center">Sorry, no portfolio entries for while.</div>'; // this is data end
- endif;
- $return_string .= ''; // wrapper will go here end
- wp_reset_query();
- return $return_string;
- }
- add_shortcode('recent-post','recent_post_shortcode');
- // shortcode will be like this
- <div class="row">
- <div class="container">
- <div class="col-md-12">
- <?php echo do_shortcode('[recent-post posts=4]');?>
- </div>
- </div>
- </div>
- // custom post
- // promo area how it works
- register_post_type( 'frost_promo',
- array(
- 'labels' => array(
- 'name' => __( 'Promos How It works' ),
- 'singular_name' => __( 'Promo' ),
- 'add_new'=>_('Add New Promo')
- ),
- 'public' => true,
- 'menu_icon'=> 'dashicons-camera', /* For Dashicons Menu */
- 'has_archive' => true,
- 'rewrite'=> array( 'slug' => 'promo' ),
- 'supports'=> array( 'title','thumbnail','editor' )
- )
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement