| 1 |
<?php |
| 2 |
/** |
| 3 |
* Portfolio Categories |
| 4 |
* |
| 5 |
* @var $attributes - attributes |
| 6 |
* @var $options - options |
| 7 |
* |
| 8 |
* @link https://codesupply.co |
| 9 |
* @since 1.0.0 |
| 10 |
* |
| 11 |
* @package Sight |
| 12 |
*/ |
| 13 |
|
| 14 |
$class_name = sight_portfolio_area_classes( $attributes, $options ); |
| 15 |
|
| 16 |
$categories = get_terms( |
| 17 |
array( |
| 18 |
'taxonomy' => 'sight-categories', |
| 19 |
'hide_empty' => false, |
| 20 |
'include' => isset( $attributes['categories_filter_ids'] ) ? $attributes['categories_filter_ids'] : '', |
| 21 |
'orderby' => isset( $attributes['categories_orderby'] ) ? $attributes['categories_orderby'] : 'name', |
| 22 |
'order' => isset( $attributes['categories_order'] ) ? $attributes['categories_order'] : 'ASC', |
| 23 |
'number' => isset( $attributes['number_items'] ) ? $attributes['number_items'] : null, |
| 24 |
) |
| 25 |
); |
| 26 |
|
| 27 |
if ( $categories ) { |
| 28 |
?> |
| 29 |
<div class="<?php echo esc_attr( $class_name ); ?>"> |
| 30 |
|
| 31 |
<div class="sight-portfolio-area__outer"> |
| 32 |
<div class="sight-portfolio-area__main" <?php sight_portfolio_area_main_attrs( $attributes, $options ); ?>> |
| 33 |
<?php |
| 34 |
// Start the Loop. |
| 35 |
foreach ( $categories as $category ) { |
| 36 |
|
| 37 |
$attachment_id = get_term_meta( $category->term_id, 'sight_featured_image', true ); |
| 38 |
|
| 39 |
// Get item project. |
| 40 |
if ( wp_get_attachment_image( $attachment_id ) ) { |
| 41 |
|
| 42 |
$portfolio_entry = new Sight_Entry( $attributes, $options ); |
| 43 |
|
| 44 |
// Set settings. |
| 45 |
$portfolio_entry->object_id = $category->term_id; |
| 46 |
$portfolio_entry->attachment_id = $attachment_id; |
| 47 |
|
| 48 |
// Init portfolio entry. |
| 49 |
$portfolio_entry->init(); |
| 50 |
|
| 51 |
require apply_filters( 'sight_portfolio_item_path', SIGHT_PATH . 'render/handler/portfolio-entry.php', $attributes, $options, $portfolio_entry ); |
| 52 |
} |
| 53 |
} |
| 54 |
?> |
| 55 |
</div> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
<?php |
| 59 |
} else { |
| 60 |
require SIGHT_PATH . 'render/handler/post-area-none.php'; |
| 61 |
} |
| 62 |
|
| 63 |
wp_reset_postdata(); |
| 64 |
|