-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathloop-portfolio.php
149 lines (123 loc) · 4.58 KB
/
loop-portfolio.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
* Loop - Portfolio
*
* This is a custom loop file, containing the looping logic for use in the "portfolio" page template,
* as well as the "portfolio-gallery" taxonomy archive screens. The custom query is only run on the page
* template, as we already have the data we need when on the taxonomy archive screens.
*
* @package WooFramework
* @subpackage Template
*/
global $woo_options;
global $more; $more = 0;
woo_loop_before();
/* Setup parameters for this loop. */
/* Make sure we only run our custom query when using the page template, and not in a taxonomy. */
$thumb_width = 210;
$thumb_height = 120;
/* Make sure our thumbnail dimensions come through from the theme options. */
if ( isset( $woo_options['woo_portfolio_thumb_width'] ) && ( $woo_options['woo_portfolio_thumb_width'] != '' ) ) {
$thumb_width = $woo_options['woo_portfolio_thumb_width'];
}
if ( isset( $woo_options['woo_portfolio_thumb_height'] ) && ( $woo_options['woo_portfolio_thumb_height'] != '' ) ) {
$thumb_height = $woo_options['woo_portfolio_thumb_height'];
}
if ( ! is_tax() ) {
$galleries = array();
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$query_args = array(
'post_type' => 'portfolio',
'paged' => $paged,
'posts_per_page' => -1
);
/* Setup portfolio galleries navigation. */
$galleries = get_terms( 'portfolio-gallery' );
$exclude_str = '';
if ( isset( $woo_options['woo_portfolio_excludenav'] ) && ( $woo_options['woo_portfolio_excludenav'] != '' ) ) {
$exclude_str = $woo_options['woo_portfolio_excludenav'];
}
// Allow child themes/plugins to filter here.
$exclude_str = apply_filters( 'woo_portfolio_gallery_exclude', $exclude_str );
/* Optionally exclude navigation items. */
if ( $exclude_str != '' ) {
$to_exclude = explode( ',', $exclude_str );
if ( is_array( $to_exclude ) ) {
foreach ( $to_exclude as $k => $v ) {
$to_exclude[$k] = str_replace( ' ', '', $v );
}
/* Remove the galleries to be excluded. */
foreach ( $galleries as $k => $v ) {
if ( in_array( $v->slug, $to_exclude ) ) {
unset( $galleries[$k] );
}
}
}
}
/* If we have galleries, make sure we only get items from those galleries. */
if ( count( $galleries ) > 0 ) {
$gallery_slugs = array();
foreach ( $galleries as $g ) { $gallery_slugs[] = $g->slug; }
$query_args['tax_query'] = array(
array(
'taxonomy' => 'portfolio-gallery',
'field' => 'slug',
'terms' => $gallery_slugs
)
);
}
/* The Query. */
query_posts( $query_args );
} // End IF Statement ( is_tax() )
/* The Loop. */
if ( have_posts() ) { $count = 0;
?>
<div id="portfolio">
<?php
/* Display the gallery navigation (from theme-functions.php). */
if ( is_page() || is_post_type_archive() ) { woo_portfolio_navigation( $galleries ); }
?>
<div class="portfolio-items">
<?php
while ( have_posts() ) { the_post(); $count++;
/* Get the settings for this portfolio item. */
$settings = woo_portfolio_item_settings( $post->ID );
/* If the theme option is set to link to the single portfolio item, adjust the $settings. */
if ( isset( $woo_options['woo_portfolio_linkto'] ) && ( $woo_options['woo_portfolio_linkto'] == 'post' ) ) {
$settings['large'] = get_permalink( $post->ID );
$settings['rel'] = '';
}
?>
<div <?php post_class( $settings['css_classes'] ); ?>>
<?php
/* Setup image for display and for checks, to avoid doing multiple queries. */
$image = woo_image( 'return=true&key=portfolio-image&width=' . $thumb_width . '&height=' . $thumb_height . '&link=img&alt=' . the_title_attribute( array( 'echo' => 0 ) ) . '' );
if ( $image != '' ) {
?>
<a <?php echo $settings['rel']; ?> title="<?php echo $settings['caption']; ?>" href="<?php echo $settings['large']; ?>" class="thumb">
<?php echo $image; ?>
</a>
<h3><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<?php
// Output image gallery for lightbox
if ( ! empty( $settings['gallery'] ) ) {
foreach ( array_slice( $settings['gallery'], 1 ) as $img => $attachment ) {
echo '<a ' . $settings['rel'] . ' title="' . $attachment['caption'] . '" href="' . $attachment['url'] . '" class="gallery-image"></a>' . "\n";
}
}
} // End IF Statement
?>
</div><!--/.group .post .portfolio-img-->
<?php
} // End WHILE Loop
?>
</div><!--/.portfolio-items-->
</div><!--/#portfolio-->
<?php
} else {
get_template_part( 'content', 'noposts' );
} // End IF Statement
rewind_posts();
woo_loop_after();
woo_pagenav();
?>