SHOW:
|
|
- or go back to the newest paste.
| 1 | # Register Custom Post | |
| 2 | function rrf_post_type() {
| |
| 3 | register_post_type( 'portfolio', | |
| 4 | array( | |
| 5 | 'labels' => array( | |
| 6 | 'name' => __( 'Portfolio' ), | |
| 7 | 'singular_name' => __( 'Portfolio' ), | |
| 8 | 'add_new' => __( 'Add New' ), | |
| 9 | 'add_new_item' => __( 'Add New Portfolio' ), | |
| 10 | 'edit_item' => __( 'Edit Portfolio' ), | |
| 11 | 'new_item' => __( 'New Portfolio' ), | |
| 12 | 'view_item' => __('portfolio'),
| |
| 13 | 'not_found' => __( 'Sorry, we couldnt find the Portfolio you are looking for.' ) | |
| 14 | ), | |
| 15 | 'public' => true, | |
| 16 | 'publicly_queryable' => true, | |
| 17 | 'exclude_from_search' => true, | |
| 18 | 'has_archive' => false, | |
| 19 | 'hierarchical' => false, | |
| 20 | 'capability_type' => 'page', | |
| 21 | 'rewrite' => array( 'slug' => 'portfolio' ), | |
| 22 | 'supports' => array( 'title', 'editor', 'custom-fields','thumbnail') | |
| 23 | ) | |
| 24 | ); | |
| 25 | } | |
| 26 | add_action( 'init', 'rrf_post_type' ); | |
| 27 | ||
| 28 | # Register Custom Taxonomy For Portfolio | |
| 29 | ||
| 30 | function rrf_post_taxonomy() {
| |
| 31 | register_taxonomy( | |
| 32 | 'portfolio_category', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). | |
| 33 | 'portfolio', //post type name | |
| 34 | array( | |
| 35 | 'hierarchical' => true, | |
| 36 | 'label' => 'Portfolio Category', //Display name | |
| 37 | 'query_var' => true, | |
| 38 | 'show_admin_column' => true, | |
| 39 | 'rewrite' => array( | |
| 40 | 'slug' => 'portfolio-category', // This controls the base slug that will display before each term | |
| 41 | 'with_front' => true // Don't display the category base before | |
| 42 | ) | |
| 43 | ) | |
| 44 | ); | |
| 45 | } | |
| 46 | add_action( 'init', 'rrf_post_taxonomy'); | |
| 47 | ||
| 48 | ||
| 49 | ||
| 50 | ||
| 51 | ||
| 52 | ||
| 53 | ====================================================== | |
| 54 | ||
| 55 | */Shortcode*/ | |
| 56 | ||
| 57 | ||
| 58 | # Dynamic Portfolio With Shortcode | |
| 59 | ||
| 60 | - | function rrf_portfolio_shortcode($atts){
|
| 60 | + | function portfolio_shortcode($atts){
|
| 61 | - | extract( shortcode_atts( array( |
| 61 | + | ob_start(); ?> |
| 62 | - | 'category' => '' |
| 62 | + | |
| 63 | - | ), $atts, '' ) ); |
| 63 | + | <div class="filter_area_wraper fix"> |
| 64 | <div class="iso-nav fix"> | |
| 65 | - | $q = new WP_Query( |
| 65 | + | <ul> |
| 66 | - | array('posts_per_page' => '-1', 'post_type' => 'portfolio')
|
| 66 | + | <li class="active" data-filter="*">כל הפריטים</li> |
| 67 | - | ); |
| 67 | + | <?php $terms = get_terms( array( |
| 68 | 'taxonomy' => 'portfolio_category', | |
| 69 | 'hide_empty' => true, | |
| 70 | - | //Portfolio taxanomy query |
| 70 | + | ) ); |
| 71 | - | $args = array( |
| 71 | + | if ( !empty( $terms ) && !is_wp_error( $terms ) ){
|
| 72 | - | 'post_type' => 'portfolio', |
| 72 | + | foreach ( $terms as $term ) { ?>
|
| 73 | - | 'paged' => $paged, |
| 73 | + | <li data-filter=".cat<?php echo $term->term_id; ?>"><?php echo $term->name; ?></li> |
| 74 | - | 'posts_per_page' => $data['portfolio_items'], |
| 74 | + | |
| 75 | <?php } | |
| 76 | } ?> | |
| 77 | - | $portfolio = new WP_Query($args); |
| 77 | + | |
| 78 | - | if(is_array($portfolio->posts) && !empty($portfolio->posts)) {
|
| 78 | + | |
| 79 | - | foreach($portfolio->posts as $gallery_post) {
|
| 79 | + | </ul> |
| 80 | - | $post_taxs = wp_get_post_terms($gallery_post->ID, 'portfolio_category', array("fields" => "all"));
|
| 80 | + | </div> |
| 81 | - | if(is_array($post_taxs) && !empty($post_taxs)) {
|
| 81 | + | |
| 82 | - | foreach($post_taxs as $post_tax) {
|
| 82 | + | <?php $docu = new WP_Query( |
| 83 | - | $portfolio_taxs[$post_tax->slug] = $post_tax->name; |
| 83 | + | array('posts_per_page' => -1, 'post_type' => 'portfolio', )
|
| 84 | - | } |
| 84 | + | ); |
| 85 | - | } |
| 85 | + | |
| 86 | ?> | |
| 87 | - | } |
| 87 | + | |
| 88 | - | if(is_array($portfolio_taxs) && !empty($portfolio_taxs) && get_post_meta($post->ID, 'pyre_portfolio_filters', true) != 'no'): |
| 88 | + | |
| 89 | - | ?> |
| 89 | + | <div class="main-iso fix"> |
| 90 | <?php | |
| 91 | - | <!--Category Filter--> |
| 91 | + | |
| 92 | - | <div class="category-filter"> |
| 92 | + | while( $docu->have_posts()) : $docu->the_post(); |
| 93 | - | <ul> |
| 93 | + | |
| 94 | - | <?php foreach($portfolio_taxs as $portfolio_tax_slug => $portfolio_tax_name): ?> |
| 94 | + | |
| 95 | - | <li class="filter" data-category="<?php echo $portfolio_tax_slug; ?>"><?php echo $portfolio_tax_name; ?></li> |
| 95 | + | |
| 96 | - | <?php endforeach; ?> |
| 96 | + | |
| 97 | - | </ul> |
| 97 | + | $item_classes .= 'cat'.$item_cat->term_id . ' '; |
| 98 | } | |
| 99 | - | <!--End--> |
| 99 | + | |
| 100 | ||
| 101 | - | <?php endif; ?> |
| 101 | + | ?> |
| 102 | ||
| 103 | - | <?php |
| 103 | + | <div class="item <?php echo $item_classes; ?> col-md-3"> |
| 104 | <div class="documentitem_wrapper fix"> | |
| 105 | - | $list = '<div class="portfolio-thumbnail"><div class="megafolio-container noborder">'; |
| 105 | + | <div class="document_title fix"> |
| 106 | - | while($q->have_posts()) : $q->the_post(); |
| 106 | + | <h2><?php the_title();?></h2> |
| 107 | - | $idd = get_the_ID(); |
| 107 | + | </div> |
| 108 | - | //$portfolio_subtitle = get_post_meta($idd, 'portfolio_subtitle', true); |
| 108 | + | <div class="document_thumb fix"> |
| 109 | - | //$filterr = get_post_meta($idd, 'filterr', true); |
| 109 | + | |
| 110 | - | $small_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio_small_image' ); |
| 110 | + | <?php if ( has_post_thumbnail() ): ?> |
| 111 | - | //$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio_large_image' ); |
| 111 | + | <?php the_post_thumbnail(); ?> |
| 112 | - | //$small_image_url = the_post_thumbnail('project_smal_image', array('class' => 'post-thumb'));
|
| 112 | + | <?php else : ?> |
| 113 | <img src="<?php echo get_template_directory_uri(); ?>/img/file_img.jpg" alt="" /> | |
| 114 | - | //Get Texanmy class |
| 114 | + | <?php endif; ?> |
| 115 | </div> | |
| 116 | <div class="document_linkarea fix"> | |
| 117 | <div class="link_downld fix"> | |
| 118 | <a href="<?php the_field('pdf_file');?>" class=
| |
| 119 | "down_kor" download>הורד</a> | | |
| 120 | - | $item_classes .= $item_cat->slug . ' '; |
| 120 | + | </div> |
| 121 | <div class="link_preview fix"> | |
| 122 | ||
| 123 | <button type="submit" onclick="window.open('<?php the_field('pdf_file');?>')" class=
| |
| 124 | - | $single_link = |
| 124 | + | "previw_kor">צפה</button> |
| 125 | - | $list .= ' |
| 125 | + | |
| 126 | </div> | |
| 127 | - | <!--Thumbnail 1 Start--> |
| 127 | + | |
| 128 | - | <div class="mega-entry '.$item_classes.'" id="" data-src="'.$small_image_url[0].'"> |
| 128 | + | |
| 129 | - | |
| 129 | + | |
| 130 | - | <!--Hover Effect Start--> |
| 130 | + | <?php endwhile; ?> |
| 131 | - | <a class="" href="'.get_permalink().'"> |
| 131 | + | |
| 132 | - | <div class="mega-hover alone notitle"> |
| 132 | + | |
| 133 | </div> | |
| 134 | - | <!-- Link Button --> |
| 134 | + | <?php wp_reset_postdata(); ?> |
| 135 | - | <div class="mega-hoverview"></div> |
| 135 | + | |
| 136 | - | |
| 136 | + | </div> |
| 137 | ||
| 138 | - | </a> |
| 138 | + | |
| 139 | - | <!--Hover Effect End--> |
| 139 | + | <?php |
| 140 | - | |
| 140 | + | |
| 141 | return ob_get_clean(); | |
| 142 | } | |
| 143 | - | '; |
| 143 | + | add_shortcode('portfolio', 'portfolio_shortcode'); |