Custom Carousel using Function.php Custom post type using shortcode [custom-post-type] example.

 /* STUDY ABROAD */

function studyabroads_register() {

 $labels = array(

  'name' => _x('Studyabroad', 'post type general name'),

  'singular_name' => _x('studyabroads', 'post type singular name'),

  'add_new' => _x('Add New', 'review'),

  'add_new_item' => __('Add New Studyabroads'),

  'edit_item' => __('Edit Studyabroads'),

  'new_item' => __('New Studyabroads'),

  'view_item' => __('View Studyabroads'),

  'search_items' => __('Search Studyabroads'),

  'not_found' =>  __('Nothing found'),

  'not_found_in_trash' => __('Nothing found in Trash'),

  'parent_item_colon' => ''

 );


 $args = array(

  'labels' => $labels,

  'public' => true,

  'publicly_queryable' => true,

  'show_ui' => true,

  'query_var' => true,

  'menu_icon' => null,

  'rewrite' => true,

  'capability_type' => 'post',

  'hierarchical' => false,

  'menu_position' => null,

  'supports' => array( 'title', 'editor', 'post_tag', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),

   ); 

  register_post_type( 'studyabroads' , $args );

}

add_action('init', 'studyabroads_register');



// After that you can create the category template for product type with this name "taxonomy-product_category.php" and show single post one page with "single-products.php" /


add_action( 'init', 'gp_register_taxonomy_for_object_type' );

function gp_register_taxonomy_for_object_type() {

    register_taxonomy_for_object_type( 'post_tag', 'studyabroads' );

};

add_action( 'init', 'sk_add_category_taxonomy_to_events' );

function sk_add_category_taxonomy_to_events() {

  register_taxonomy_for_object_type( 'category', 'studyabroads' );

}

// create shortcode to list all products which come in blue //


/*SHORT CODE FOR HOME POST */


function sc_study_post($atts, $content = null) {

        extract(shortcode_atts(array(

                "num" => '',

                "cat" => '',

"tag"=>''

                   ), $atts));

global $studyabroads;

 

$args = array(  

  'posts_per_page' => $num,

  'offset' => 0,

  'post_status' => 'publish',

  'ignore_sticky_posts' => 0,

  'orderby' => 'date',

  'order' => 'ASC',

  'post_type' => 'studyabroads', 

   'tag_id'=>$tag,

   'cat'=> $cat

);


$query = new WP_Query( $args );

   

    if ( $query->have_posts() ) { ?>


   <div class="row">

<div class="MultiCarousel" data-items="1,3,5,6" data-slide="1" id="MultiCarousel"  data-interval="1000">

            <div class="MultiCarousel-inner">

<?php while ( $query->have_posts() ) : $query->the_post(); ?>

                <div class="item">

                    <div class="pad15">

<?php the_post_thumbnail(); ?>

<h3 class="text-center"><?php echo get_the_title(); ?></h3>

<p class="contents text-center"><?php echo get_the_content(); ?></p>

<p class="text-center"><a title="" href="<?php echo get_the_excerpt(); ?>">Learn More</a></p>

                    </div>

                </div> 

<?php 

endwhile;

            wp_reset_postdata(); ?> 

            </div>

            <button class="btn btn-primary leftLst"><span class="glyphicon glyphicon-chevron-left"></span></button>

            <button class="btn btn-primary rightLst"><span class="glyphicon glyphicon-chevron-right"></span></button>

        </div>

</div>

  

<?php }

}

add_shortcode("study_post_list", "sc_study_post");

/* STUDY ABROAD END */

Comments

Popular posts from this blog

Get Post Data From Simple Post custom shortcode

Top 20 Beautiful Pen For Writing

Fatal error: Maximum execution time of 300 seconds exceeded in C:\xampp\phpMyAdmin\libraries\classes\Dbi\DbiMysqli.php on line 199