Exemplo n.º 1
0
/**
 * The Shortcode
 */
function web_portfolio_shortcode($atts)
{
    extract(shortcode_atts(array('type' => 'fullwidth', 'pppage' => '999', 'filter' => 'all', 'show_filter' => 1), $atts));
    /**
     * Initial query args
     */
    $query_args = array('post_type' => 'portfolio', 'posts_per_page' => $pppage);
    if (!($filter == 'all')) {
        if (function_exists('icl_object_id')) {
            $filter = (int) icl_object_id($filter, 'portfolio_category', true);
        }
        $query_args['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'id', 'terms' => $filter));
    }
    /**
     * Finally, here's the query.
     */
    $block_query = new WP_Query($query_args);
    ob_start();
    ?>

<section class="no-pad-bottom projects-gallery">
		<div class="projects-wrapper clearfix">
		
			<?php 
    if ('Contained Portfolio' == $type) {
        echo '<div class="divide60"></div>';
    }
    if ('Fullwidth Portfolio' == $type) {
        echo '<h2>Сделано</h2>';
    }
    if ('Yes' == $show_filter) {
        $cats = get_categories('taxonomy=portfolio_category');
        echo web_portfolio_filters($cats);
    }
    ?>
	
			<?php 
    if ('Fullwidth Portfolio' == $type) {
        ?>
 
					
				<div class="projects-container">
				
					<?php 
        if ($block_query->have_posts()) {
            while ($block_query->have_posts()) {
                $block_query->the_post();
                /**
                 * Get blog posts by blog layout.
                 */
                get_template_part('template_parts/content', 'portfolio-fullwidth');
            }
        } else {
            /**
             * Display no posts message if none are found.
             */
            get_template_part('template_parts/content', 'none');
        }
        wp_reset_query();
        ?>
				
				</div><!--end of projects-container-->
				
			<?php 
    } elseif ('2 Column Fullwidth' == $type) {
        ?>
			
				<div class="projects-container">
				
					<?php 
        if ($block_query->have_posts()) {
            while ($block_query->have_posts()) {
                $block_query->the_post();
                /**
                 * Get blog posts by blog layout.
                 */
                get_template_part('template_parts/content', 'portfolio-half');
            }
        } else {
            /**
             * Display no posts message if none are found.
             */
            get_template_part('template_parts/content', 'none');
        }
        wp_reset_query();
        ?>
				
				</div><!--end of projects-container-->
				
			<?php 
    } elseif ('4 Column Fullwidth' == $type) {
        ?>
			
				<div class="projects-container">
				
					<?php 
        if ($block_query->have_posts()) {
            while ($block_query->have_posts()) {
                $block_query->the_post();
                /**
                 * Get blog posts by blog layout.
                 */
                get_template_part('template_parts/content', 'portfolio-quarter');
            }
        } else {
            /**
             * Display no posts message if none are found.
             */
            get_template_part('template_parts/content', 'none');
        }
        wp_reset_query();
        ?>
				
				</div><!--end of projects-container-->
		
			<?php 
    } elseif ('Contained Portfolio' == $type) {
        ?>
				
				<div class="row">
					<div class="projects-container column-projects">
						<?php 
        if ($block_query->have_posts()) {
            while ($block_query->have_posts()) {
                $block_query->the_post();
                /**
                 * Get blog posts by blog layout.
                 */
                get_template_part('template_parts/content', 'portfolio-contained');
            }
        } else {
            /**
             * Display no posts message if none are found.
             */
            get_template_part('template_parts/content', 'none');
        }
        wp_reset_query();
        ?>
					</div><!--end of projects-container-->
				</div>

			<?php 
    }
    ?>

		</div><!--end of projects wrapper-->
</section>
			
<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Exemplo n.º 2
0
    function block($instance)
    {
        extract($instance);
        /**
         * Initial query args
         */
        $query_args = array('post_type' => 'portfolio', 'posts_per_page' => $pppage);
        /**
         * If we're choosing just 1 category, add more args.
         * ALL THE ARGS!
         */
        if (!($filter == 'all')) {
            if (function_exists('icl_object_id')) {
                $filter = (int) icl_object_id($filter, 'portfolio_category', true);
            }
            $query_args['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'id', 'terms' => $filter));
        }
        /**
         * Finally, here's the query.
         */
        $block_query = new WP_Query($query_args);
        /**
         * Now let's grab categories for the animated portfolio filter buttons
         */
        $cats = $filter == 'all' ? get_categories('taxonomy=portfolio_category') : get_categories('taxonomy=portfolio_category&exclude=' . $filter . '&child_of=' . $filter);
        ?>
	
		<section class="no-pad-bottom projects-gallery">
			<div class="projects-wrapper clearfix">
			
				<?php 
        if ('contained' == $type) {
            echo '<div class="divide60"></div>';
        }
        if (1 == $show_filter) {
            echo web_portfolio_filters($cats);
        }
        ?>
		
				<?php 
        if ('fullwidth' == $type) {
            ?>

					<div class="projects-container">
					
						<?php 
            if ($block_query->have_posts()) {
                while ($block_query->have_posts()) {
                    $block_query->the_post();
                    /**
                     * Get blog posts by blog layout.
                     */
                    get_template_part('template_parts/content', 'portfolio-fullwidth');
                }
            } else {
                /**
                 * Display no posts message if none are found.
                 */
                get_template_part('template_parts/content', 'none');
            }
            wp_reset_query();
            ?>
					
					</div><!--end of projects-container-->
					
				<?php 
        } elseif ('half' == $type) {
            ?>
				
					<div class="projects-container">
					
						<?php 
            if ($block_query->have_posts()) {
                while ($block_query->have_posts()) {
                    $block_query->the_post();
                    /**
                     * Get blog posts by blog layout.
                     */
                    get_template_part('template_parts/content', 'portfolio-half');
                }
            } else {
                /**
                 * Display no posts message if none are found.
                 */
                get_template_part('template_parts/content', 'none');
            }
            wp_reset_query();
            ?>
					
					</div><!--end of projects-container-->
					
				<?php 
        } elseif ('quarter' == $type) {
            ?>
				
					<div class="projects-container">
					
						<?php 
            if ($block_query->have_posts()) {
                while ($block_query->have_posts()) {
                    $block_query->the_post();
                    /**
                     * Get blog posts by blog layout.
                     */
                    get_template_part('template_parts/content', 'portfolio-quarter');
                }
            } else {
                /**
                 * Display no posts message if none are found.
                 */
                get_template_part('template_parts/content', 'none');
            }
            wp_reset_query();
            ?>
					
					</div><!--end of projects-container-->
			
				<?php 
        } elseif ('contained' == $type) {
            ?>
					
					<div class="row">
						<div class="projects-container column-projects">
							<?php 
            if ($block_query->have_posts()) {
                while ($block_query->have_posts()) {
                    $block_query->the_post();
                    /**
                     * Get blog posts by blog layout.
                     */
                    get_template_part('template_parts/content', 'portfolio-contained');
                }
            } else {
                /**
                 * Display no posts message if none are found.
                 */
                get_template_part('template_parts/content', 'none');
            }
            wp_reset_query();
            ?>
						</div><!--end of projects-container-->
					</div>
			
				<?php 
        }
        ?>
	
			</div><!--end of projects wrapper-->
		</section>
	
	<?php 
    }