Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'my_theme_custom_post' );
- function my_theme_custom_post() {
- register_post_type( 'gallery-items',
- array(
- 'labels' => array(
- 'name' => __( 'Gallery Photo', 'wheelmasters' ),
- 'all_items' => __( 'All Gallery Photo', 'wheelmasters' ),
- 'singular_name' => __( 'Gallery Photo', 'wheelmasters' ),
- 'add_new' => __( 'Add New Gallery', 'wheelmasters' ),
- 'add_new_item' => __( 'Add New Gallery', 'wheelmasters' )
- ),
- 'public' => true,
- 'publicly_queryable' => true,
- 'menu_icon' => 'dashicons-schedule',
- 'supports' => array('title'),
- 'has_archive' => true,
- 'rewrite' => array('slug' => 'gallery-photo'),
- )
- );
- }
- function my_custom_post_taxonomy() {
- register_taxonomy(
- 'gallery_cat',
- 'gallery-items',
- array(
- 'hierarchical' => true,
- 'label' => 'Gallery Category',
- 'query_var' => true,
- 'show_admin_column' => true,
- 'rewrite' => array(
- 'slug' => 'gallery-cat',
- 'with_front' => true
- )
- )
- );
- }
- add_action( 'init', 'my_custom_post_taxonomy');
- function kingrussel_scripts() {
- global $wp_styles;
- wp_enqueue_script( 'script-jegpop', '//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js', array('jquery'), '1.1.0', false );
- wp_register_style( 'style-pop', '//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css', array(), '1.1.0', 'all' );
- wp_enqueue_style( 'style-pop');
- }
- add_action( 'wp_enqueue_scripts', 'kingrussel_scripts' );
- function krproduct_shortcode($atts){
- ob_start();
- extract( shortcode_atts( array(
- 'cat' => '',
- ), $atts, 'jeg_gallery' ) );
- ?>
- <style type="text/css">
- .hire_tab_main_area{
- margin-bottom: 10px;
- float: left; width: 100%;
- }
- .hire_tab_list{
- float: left;
- width: 100%;
- margin-right: 1%;
- }
- .hire_tab_list ul.tabs{text-align:center}
- .hire_tab_list ul.tabs li{
- display: inline-block;
- color: #000; padding: 10px 20px;
- }
- .hire_tab_content{
- float: left;
- width: 100%; margin: 10px 0;
- }
- .hire_tab_content .tab-content ul {}
- .hire_tab_content .tab-content ul li {
- float: left;
- width: 25%;
- padding: 10px; margin: 0;min-height: 250px;
- }
- .hire_tab_content .tab-content ul li:before {
- display: none;
- }
- .hire_tab_content .tab-content{}
- .tab_content_title{}
- .tab_content_title h1{}
- ul.tabs{
- margin: 0px;
- padding: 0px;
- list-style: none;
- }
- ul.tabs li{
- background: none;
- color: #fff;
- display: inline-block;
- padding: 0 5px;
- cursor: pointer;
- border: 1px solid;
- }
- .hire_tab_list ul.tabs li:before{display:none}
- ul.tabs li.current{
- background: #9f2141;
- color: #fff;border: 1px solid #cc9f53;
- }
- .tab-content{
- display: none;
- padding: 0 5px;
- line-height: 20px;
- }
- .tab-content.current{
- display: inherit;
- }
- /* Mobile Layout: 320px. */
- @media only screen and (max-width: 767px) {
- .hire_tab_content .tab-content ul li { width: 100%; padding: 0; margin: 0; min-height: auto; margin-bottom: 10px;}
- .hire_tab_list ul.tabs li { padding: 6px 10px; font-size: 12px;}
- }
- </style>
- <div class="hire_tab_main_area">
- <div class="hire_tab_list">
- <ul class="tabs">
- <?php $ctr = 0;
- $my_query = new WP_Query(array(
- 'post_type' => 'gallery-items',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'gallery_cat' => $cat,
- ));?>
- <li class="tab-link current" data-tab="tab-all">All</li>
- <?php
- if($my_query->have_posts()):
- while($my_query->have_posts()): $my_query->the_post();
- //$class = $ctr == 0 ? ' current' : '';
- ?>
- <li class="tab-link" data-tab="tab-<?php the_ID(); ?>"><?php the_title();?></li>
- <?php $ctr++;
- endwhile; endif; wp_reset_query(); ?>
- </ul>
- </div>
- <div class="hire_tab_content">
- <?php
- $taball_query = new WP_Query(array(
- 'post_type' => 'gallery-items',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'gallery_cat' => $cat,
- ));?>
- <div id="tab-all" class="tab-content current">
- <?php
- if($taball_query->have_posts()):
- while($taball_query->have_posts()): $taball_query->the_post();
- ?>
- <?php
- $images = get_field('upload_your_images_here');
- if( $images ): ?>
- <ul class="gallery">
- <?php foreach( $images as $image ): ?>
- <li class="gallery-popup">
- <a class="popup-link" href="<?php echo $image['url']; ?>" title="<?php echo $image['title']; ?>">
- <img src="<?php echo $image['sizes']['large']; ?>" alt="<?php echo $image['alt']; ?>" />
- <p style="text-align:center"><?php echo $image['title']; ?></p>
- </a>
- </li>
- <?php endforeach; ?>
- </ul>
- <?php endif; ?>
- <?php endwhile; endif; wp_reset_query();?>
- </div>
- <?php $ctrcont = 0;
- $tab_query = new WP_Query(array(
- 'post_type' => 'gallery-items',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'gallery_cat' => $cat,
- ));
- if($tab_query->have_posts()):
- while($tab_query->have_posts()): $tab_query->the_post();
- //$class = $ctrcont == 0 ? ' current' : '';
- ?>
- <div id="tab-<?php the_ID(); ?>" class="tab-content">
- <?php
- $images = get_field('upload_your_images_here');
- if( $images ): ?>
- <ul class="gallery">
- <?php foreach( $images as $image ): ?>
- <li class="gallery-popup">
- <a class="popup-link" href="<?php echo $image['url']; ?>" title="<?php echo $image['title']; ?>">
- <img src="<?php echo $image['sizes']['large']; ?>" alt="<?php echo $image['alt']; ?>" />
- <p style="text-align:center"><?php echo $image['title']; ?></p>
- </a>
- </li>
- <?php endforeach; ?>
- </ul>
- <?php endif; ?>
- </div>
- <?php $ctrcont++;
- endwhile; endif; wp_reset_query();?>
- </div>
- </div>
- <script type="text/javascript">
- jQuery('ul.tabs li').click(function(){
- var tab_id = jQuery(this).attr('data-tab');
- jQuery('ul.tabs li').removeClass('current');
- jQuery('.tab-content').removeClass('current');
- jQuery(this).addClass('current');
- jQuery("#"+tab_id).addClass('current');
- })
- jQuery('ul.gallery').each(function() { // the containers for all your galleries
- jQuery(this).magnificPopup({
- delegate: 'a', // the selector for gallery item
- type: 'image',
- gallery: {
- enabled:true
- }
- });
- });
- </script>
- <?php return ob_get_clean();
- }
- add_shortcode('jeg_gallery', 'krproduct_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment