Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Register Custom Post
- function rrf_post_type() {
- register_post_type( 'portfolio',
- array(
- 'labels' => array(
- 'name' => __( 'Portfolio' ),
- 'singular_name' => __( 'Portfolio' ),
- 'add_new' => __( 'Add New' ),
- 'add_new_item' => __( 'Add New Portfolio' ),
- 'edit_item' => __( 'Edit Portfolio' ),
- 'new_item' => __( 'New Portfolio' ),
- 'view_item' => __('portfolio'),
- 'not_found' => __( 'Sorry, we couldnt find the Portfolio you are looking for.' )
- ),
- 'public' => true,
- 'publicly_queryable' => true,
- 'exclude_from_search' => true,
- 'has_archive' => false,
- 'hierarchical' => false,
- 'capability_type' => 'page',
- 'rewrite' => array( 'slug' => 'portfolio' ),
- 'supports' => array( 'title', 'editor', 'custom-fields','thumbnail')
- )
- );
- }
- add_action( 'init', 'rrf_post_type' );
- # Register Custom Taxonomy For Portfolio
- function rrf_post_taxonomy() {
- register_taxonomy(
- 'portfolio_category', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
- 'portfolio', //post type name
- array(
- 'hierarchical' => true,
- 'label' => 'Portfolio Category', //Display name
- 'query_var' => true,
- 'show_admin_column' => true,
- 'rewrite' => array(
- 'slug' => 'portfolio-category', // This controls the base slug that will display before each term
- 'with_front' => true // Don't display the category base before
- )
- )
- );
- }
- add_action( 'init', 'rrf_post_taxonomy');
- ======================================================
- */Shortcode*/
- # Dynamic Portfolio With Shortcode
- function portfolio_shortcode($atts){
- ob_start(); ?>
- <div class="filter_area_wraper fix">
- <div class="iso-nav fix">
- <ul>
- <li class="active" data-filter="*">כל הפריטים</li>
- <?php $terms = get_terms( array(
- 'taxonomy' => 'portfolio_category',
- 'hide_empty' => true,
- ) );
- if ( !empty( $terms ) && !is_wp_error( $terms ) ){
- foreach ( $terms as $term ) { ?>
- <li data-filter=".cat<?php echo $term->term_id; ?>"><?php echo $term->name; ?></li>
- <?php }
- } ?>
- </ul>
- </div>
- <?php $docu = new WP_Query(
- array('posts_per_page' => -1, 'post_type' => 'portfolio', )
- );
- ?>
- <div class="main-iso fix">
- <?php
- while( $docu->have_posts()) : $docu->the_post();
- $item_classes = '';
- $item_cats = get_the_terms($post->ID, 'portfolio_category');
- if($item_cats):
- foreach($item_cats as $item_cat) {
- $item_classes .= 'cat'.$item_cat->term_id . ' ';
- }
- endif;
- ?>
- <div class="item <?php echo $item_classes; ?> col-md-3">
- <div class="documentitem_wrapper fix">
- <div class="document_title fix">
- <h2><?php the_title();?></h2>
- </div>
- <div class="document_thumb fix">
- <?php if ( has_post_thumbnail() ): ?>
- <?php the_post_thumbnail(); ?>
- <?php else : ?>
- <img src="<?php echo get_template_directory_uri(); ?>/img/file_img.jpg" alt="" />
- <?php endif; ?>
- </div>
- <div class="document_linkarea fix">
- <div class="link_downld fix">
- <a href="<?php the_field('pdf_file');?>" class=
- "down_kor" download>הורד</a> |
- </div>
- <div class="link_preview fix">
- <button type="submit" onclick="window.open('<?php the_field('pdf_file');?>')" class=
- "previw_kor">צפה</button>
- </div>
- </div>
- </div>
- </div>
- <?php endwhile; ?>
- </div>
- <?php wp_reset_postdata(); ?>
- </div>
- <?php
- return ob_get_clean();
- }
- add_shortcode('portfolio', 'portfolio_shortcode');
Add Comment
Please, Sign In to add comment