| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- /*------------------------------------------------------*/
- /* taskereasy Heading
- /*------------------------------------------------------*/
- vc_map(array(
- "name" => esc_html__("Blog Posts", 'taskereasy'),
- "base" => "taskereasy_blog_post",
- 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
- "class" => "",
- "description" => esc_html__("Add taskereasy blog post type", 'taskereasy'),
- "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
- "params" => array(
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Style", 'taskereasy'),
- "param_name" => "style",
- "value" => array('Style 1' => 'style_1', 'Style 2' => 'style_2'),
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Post Columns", 'taskereasy'),
- "param_name" => "post_coloumns",
- "value" => array('Three columns' => '3', 'Four columns' => '4'),
- ),
- array(
- 'type' => 'css_editor',
- 'heading' => esc_html__( 'CSS', 'taskereasy' ),
- 'param_name' => 'custom_design',
- 'group' => esc_html__( 'Design options', 'taskereasy' ),
- )
- )
- ));
- add_shortcode( 'taskereasy_blog_post', function($atts, $content = null) {
- extract(shortcode_atts(array(
- 'style' => 'style_1',
- 'post_coloumns' => '3',
- 'custom_design' => '',
- ), $atts));
- $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
- $postcoloumns = html_entity_decode(vc_value_from_safe($post_coloumns, true));
- $output = '';
- $args = array(
- 'post_type' => 'post',
- 'orderby' => 'date',
- 'order' => 'desc',
- 'posts_per_page' => $postcoloumns,
- );
- $the_query = new WP_Query( $args );
- $output .= '<div class="row '.$custom_design.'">';
- if ( $the_query->have_posts() ) :
- global $post;
- while ( $the_query->have_posts() ) : $the_query->the_post();
- $col_num = ($postcoloumns == 4)? '3' : '4';
- $output .='
- <article class="col-lg-'.esc_attr($col_num).'">';
- if($style == 'style_1'){
- //Style 1
- $output.=
- '<div class="post-wrap p-0">
- <div class="post-img dark-shadow">';
- if(has_post_thumbnail()){
- $output .= '<a href="'.get_the_permalink().'">'.get_the_post_thumbnail().'</a>';
- }
- $output .=
- '</div>
- <div class="post-info">
- <h4><a href="'.get_the_permalink().'">'.get_the_title().'</a></h4>
- </div>
- </div>';
- }else{
- //Style 2
- $output.=
- '<div class="offer-4-container">';
- if(has_post_thumbnail()){
- $output .= '<a href="'.get_the_permalink().'">'.get_the_post_thumbnail().'</a>';
- }
- $output.='
- <div class="offer-container">
- <h4><a href="'.get_the_permalink().'">'.get_the_title().'</a></h4>
- <p>'.taskereasy_custom_excerpt_length(10).'</p>
- </div>
- <a href="'.get_the_permalink().'" class="btn">'.esc_html__("Read More", "taskereasy").'</a>
- </div>';
- }
- $output.='
- </article>';
- endwhile;
- wp_reset_postdata();
- else :
- $output .= '<p>'.esc_html__( 'Sorry, no posts matched your criteria.', 'taskereasy' ) .'</p>';
- endif;
- $output .= '</div>';
- return $output;
- });
|