Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit; # Exit if accessed directly
- }
- # Upcoming posts
- add_shortcode( 'themeum_topheadline', function($atts, $content = null){
- extract(shortcode_atts(array(
- 'post_category' => '',
- 'slidecolumn' => '',
- 'title' => '',
- 'introtext' => '',
- 'count' => '3',
- 'order' => 'DESC',
- 'order_by' => 'date',
- 'class' => '',
- 'slidenav' => 'true',
- 'autoplay' => 'true',
- ), $atts));
- global $post;
- $output = '';
- $posts= 0;
- if (isset($category) && $category!='') {
- $idObj = get_category_by_slug( $category );
- if (isset($idObj) && $idObj!='') {
- $idObj = get_category_by_slug( $category );
- $cat_id = $idObj->term_id;
- $args = array(
- 'category' => $cat_id,
- 'orderby' => 'meta_value_num',
- 'meta_key' => 'themeum_headline',
- 'order' => $order,
- 'posts_per_page' => $number,
- );
- $posts = get_posts($args);
- }
- }else{
- $args = array(
- 'orderby' => 'meta_value_num',
- 'meta_key' => 'themeum_headline',
- 'order' => $order,
- 'posts_per_page' => $number,
- );
- $posts = get_posts($args);
- }
- $output .= '<div class="topheadline '.esc_attr($class).'">';
- $output .= '<div data-number="'.esc_attr($slidecolumn).'" class="jihad owl-carousel owl-theme '.esc_attr($layout).'">';
- if( count($posts) > 0 ){
- foreach ($posts as $key=>$post) {
- setup_postdata( $post );
- $output .= '<div class="themeum-course-in item">';
- if ( has_post_thumbnail()) {
- $output .= '<a class="review-item-image" href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'wpeducon-small', array('class' => 'img-responsive')).'</a>';
- }
- $output .= '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
- $output .= '</div>';//themeum-feature-course
- }
- wp_reset_postdata();
- }
- $output .= '</div>';//themeum-feature-course
- $output .= '</div>';//adons-themeum-feature-carosuel
- return $output;
- });
- function themeum_category_list(){
- $cat_lists = get_categories();
- $all_cat_list = array('All Category'=>'');
- foreach($cat_lists as $cat_list){
- $all_cat_list[$cat_list->cat_name] = $cat_list->cat_name;
- }
- return $all_cat_list;
- }
- # Visual Composer
- if (class_exists('WPBakeryVisualComposerAbstract')) {
- vc_map(array(
- "name" => esc_html__("Top Headline", 'themeum-core'),
- "base" => "themeum_topheadline",
- 'icon' => 'icon-thm-title',
- "class" => "",
- "description" => esc_html__("Widget Title Heading", 'themeum-core'),
- "category" => esc_html__('Educon', 'themeum-core'),
- "params" => array(
- array(
- "type" => "dropdown",
- "heading" => __("Category Filter", "themeum-core"),
- "param_name" => "post_category",
- "value" => themeum_category_list(),
- ),
- array(
- "type" => "textfield",
- "heading" => __("Title", "themeum-core"),
- "param_name" => "title",
- "value" => "",
- "admin_label" =>true,
- ),
- array(
- "type" => "textarea",
- "heading" => __("Intro Text", "themeum-core"),
- "param_name" => "introtext",
- "value" => "",
- ),
- array(
- "type" => "dropdown",
- "class" => "",
- "heading" => esc_html__("Select Column Number",'themeum-core'),
- "param_name" => "slidecolumn",
- "value" => array(
- esc_html__("Select",'themeum-core') =>'',
- esc_html__("Column 1",'themeum-core') => '1',
- esc_html__("Column 2",'themeum-core') => '2',
- esc_html__("Column 3",'themeum-core') => '3',
- esc_html__("Column 4",'themeum-core') => '4',
- esc_html__("Column 5",'themeum-core') => '5',
- ),
- ),
- array(
- "type" => "textfield",
- "heading" => __("Number of posts", "themeum-core"),
- "param_name" => "count",
- "value" => "",
- ),
- array(
- "type" => "dropdown",
- "class" => "",
- "heading" => __("Auto Play",'themeum-core'),
- "param_name" => "autoplay",
- "value" => array('None'=>'','True'=>'true','False'=>'false'),
- "dependency" => Array("element" => "layout", "value" => array("carosuel")),
- ),
- array(
- "type" => "dropdown",
- "class" => "",
- "heading" => __("Show Navigation",'themeum-core'),
- "param_name" => "slidenav",
- "value" => array('None'=>'','True'=>'true','False'=>'false'),
- "dependency" => Array("element" => "layout", "value" => array("carosuel")),
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Order", 'themeum-core'),
- "param_name" => "order",
- "value" => array('None'=>'','DESC'=>'DESC','ASC'=>'ASC'),
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("OderBy", 'themeum-core'),
- "param_name" => "order_by",
- "value" => array('None'=>'','Date'=>'date','Title'=>'title','Modified'=>'modified','Author'=>'author','Random'=>'rand'),
- ),
- array(
- "type" => "textfield",
- "heading" => esc_html__("Extra CSS Class", "themeum-core"),
- "param_name" => "class",
- "value" => "",
- ),
- )
- ));
- }
- ?>
- <script type="text/javascript">
- var $headline = $('.jihad');
- var $testicount = $headline.data('number');
- var $testiautoplay = $headline.data('aplay');
- var $testnav = $headline.data('testnav');
- $headline.owlCarousel({
- loop:true,
- dots:false,
- nav:true,
- margin:30,
- rtl:rtl,
- autoplay:$testiautoplay,
- autoplayTimeout:3000,
- autoplayHoverPause:true,
- autoHeight: false,
- smartSpeed:400,
- nav:$testnav,
- navText: ['<i class="fa fa-angle-left">','<i class="fa fa-angle-right">'],
- lazyLoad:false,
- responsive:{
- 0:{
- items:1
- },
- 600:{
- items:1
- },
- 1000:{
- items: $testicount,
- }
- },
- onInitialized: function() {
- $('.owl-item.active').first().addClass('last-owl-active-item');
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement