Custom Post type
Wed Nov 15 2023 09:36:53 GMT+0000 (Coordinated Universal Time)
Saved by @irfanelahi1 #classic #editor
unction slick_cdn_enqueue_scripts(){ wp_enqueue_style( 'slick-style', '//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css' ); wp_enqueue_script( 'slick-script', '//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js', array(), null, true ); } add_action( 'wp_enqueue_scripts', 'slick_cdn_enqueue_scripts' ); /----------------------- Custom Post type Services ------------------------------------/ //Services Post Type add_action('init', 'services_post_type_init'); function services_post_type_init() { $labels = array( 'name' => __('Services', 'post type general name', ''), 'singular_name' => __('Services', 'post type singular name', ''), 'add_new' => __('Add New', 'Services', ''), 'add_new_item' => __('Add New Services', ''), 'edit_item' => __('Edit Services', ''), 'new_item' => __('New Services', ''), 'view_item' => __('View Services', ''), 'search_items' => __('Search Services', ''), 'not_found' => __('No Services found', ''), 'not_found_in_trash' => __('No Services found in Trash', ''), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'rewrite' => true, 'query_var' => true, 'menu_icon' => get_stylesheet_directory_uri() . '/images/testimonials.png', 'capability_type' => 'post', 'hierarchical' => true, 'public' => true, 'has_archive' => true, 'show_in_nav_menus' => true, 'menu_position' => null, 'rewrite' => array( 'slug' => 'services', 'with_front' => true ), 'supports' => array( 'title', 'editor', 'thumbnail' ) ); register_post_type('services', $args); } ============================= SHORTCODE ============================= // Add Shortcode [our_services]; add_shortcode('our_services', 'codex_our_services'); function codex_our_services() { ob_start(); wp_reset_postdata(); ?> <div class="row "> <div id="owl-demo" class="owl-carousel ser-content"> <?php $arg = array( 'post_type' => 'services', 'posts_per_page' => -1, ); $po = new WP_Query($arg); ?> <?php if ($po->have_posts()) : ?> <?php while ($po->have_posts()) : ?> <?php $po->the_post(); ?> <div class="item"> <div class="ser-body"> <a href="#"> <div class="thumbnail-blog"> <?php echo get_the_post_thumbnail(get_the_ID(), 'full'); ?> </div> <div class="content"> <h3 class="title"><?php the_title(); ?></h3> <!-- <p><?php //echo wp_trim_words(get_the_content(), 25, '...'); ?></p> --> </div> </a> <div class="readmore"> <a href="<?php echo get_permalink() ?>">Read More</a> </div> </div> </div> <?php endwhile; ?> <?php endif; ?> </div> </div> <?php wp_reset_postdata(); return '' . ob_get_clean(); }
/----If we want to start slider in post type insert this code for cdn files--------/
https://www.advancedcustomfields.com/resources/
Comments