Ejemplo n.º 1
0
function get_etheme_portfolio($categories = false, $limit = false, $show_pagination = true)
{
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $tax_query = array();
    if (!$limit) {
        $limit = etheme_get_option('portfolio_count');
    }
    if (is_array($categories) && !empty($categories)) {
        $tax_query = array(array('taxonomy' => 'categories', 'field' => 'id', 'terms' => $categories, 'operator' => 'IN'));
    } else {
        if (!is_array($categories) && !empty($categories)) {
            $categories = explode(',', $categories);
            $tax_query = array(array('taxonomy' => 'categories', 'field' => 'id', 'terms' => $categories, 'operator' => 'IN'));
        }
    }
    $args = array('post_type' => 'etheme_portfolio', 'paged' => $paged, 'posts_per_page' => $limit, 'tax_query' => $tax_query);
    $loop = new WP_Query($args);
    if ($loop->have_posts()) {
        ?>
			<div>
				<ul class="portfolio-filters">
					<li><a href="#" data-filter="*" class="button active"><?php 
        _e('Show All', ETHEME_DOMAIN);
        ?>
</a></li>
						<?php 
        $categories = get_terms('categories', array('include' => $categories));
        $catsCount = count($categories);
        $_i = 0;
        foreach ($categories as $category) {
            $_i++;
            ?>
								<li><a href="#" data-filter=".sort-<?php 
            echo $category->slug;
            ?>
" class="button"><?php 
            echo $category->name;
            ?>
</a></li>
							<?php 
        }
        ?>
				</ul>
			
				<div class="row portfolio masonry">
				<?php 
        while ($loop->have_posts()) {
            $loop->the_post();
            ?>

					<?php 
            get_template_part('content', 'portfolio');
            ?>

				<?php 
        }
        ?>
				</div>
			</div>

		<?php 
        if ($show_pagination) {
            ?>
			<?php 
            etheme_portfolio_pagination($loop, $paged);
            ?>
		<?php 
        }
        ?>
		
	<?php 
    } else {
        ?>

		<h3><?php 
        _e('No pages were found!', ETHEME_DOMAIN);
        ?>
</h3>

	<?php 
    }
}
Ejemplo n.º 2
0
    while ($loop->have_posts()) {
        $loop->the_post();
        ?>
			
								<?php 
        get_template_part('content', 'portfolio');
        ?>
			
							<?php 
    }
    ?>
						</div>
						
						
						<?php 
    etheme_portfolio_pagination($loop, $paged);
    ?>
						
					<?php 
} else {
    ?>
                        <h3 class="page-title"><?php 
    _e('Nothing Found', ETHEME_DOMAIN);
    ?>
</h3>
        			<?php 
}
?>
        			
			</div><!-- #content -->
            <div class="clear"></div>