forked from themebeans/trim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent-portfolio.php
113 lines (92 loc) · 2.83 KB
/
content-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
<?php
/**
* The file for displaying the portfolio template's primary content.
* It is pulled by the portfolio template files and is setup to reflect both templates.
*
* @package Trim
* @link https://themebeans.com/themes/trim
*/
// PULL PAGINATION FROM CUSTOMIZATION
$portfolio_posts_count = get_theme_mod( 'portfolio_posts_count', trim_defaults( 'portfolio_posts_count' ) );
// PULL PAGINATION FROM READING SETTINGS
$paged = 1;
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var( 'paged' );
}
if ( get_query_var( 'page' ) ) {
$paged = get_query_var( 'page' );
}
// GET THE LOOP ORDERBY & META_KAY VARIABLES VIA THEME CUSTOMIZER
$orderby = get_theme_mod( 'portfolio_loop_orderby', trim_defaults( 'portfolio_loop_orderby' ) );
// LOOP ORDERBY VARIABLE
if ( $orderby != '' ) {
switch ( $orderby ) {
case 'date':
$order = 'DSC';
$orderby = 'date';
$meta_key = '';
break;
case 'rand':
$order = 'DSC';
$orderby = 'rand';
$meta_key = '';
break;
case 'menu_order':
$order = 'ASC';
$orderby = 'menu_order';
$meta_key = '';
break;
case 'view_count':
$order = 'DSC';
$orderby = 'meta_value_num';
$meta_key = 'post_views_count';
break;
}
}
// TEMPLATE SWITCHER
if ( is_page_template( 'template-portfolio-fullwidth.php' ) ) {
get_template_part( 'content-portfolio-fullwidth' );
} elseif ( is_page_template( 'template-portfolio-fullscreen-slider.php' ) ) {
get_template_part( 'content-portfolio-fullscreen-slider' );
} else {
// LAYOUT SWITCHER
$theme_version = get_theme_mod( 'theme_version', trim_defaults( 'theme_version' ) );
if ( $theme_version == 'theme_version_fullwidth' ) {
get_template_part( 'content-portfolio-fullwidth' );
} elseif ( $theme_version == 'theme_version_fullscreen' ) {
get_template_part( 'content-portfolio-fullscreen-slider' );
} else {
if ( is_tax() ) {
global $query_string;
query_posts( "{$query_string}&posts_per_page=-1" );
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
get_template_part( 'loop-portfolio' );
endwhile;
endif;
wp_reset_postdata();
} else {
// LOAD PORTFOLIO QUERY
$args = array(
'post_type' => 'portfolio',
'order' => $order,
'orderby' => $orderby,
'paged' => $paged,
'meta_key' => $meta_key,
'posts_per_page' => $portfolio_posts_count,
);
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) :
$wp_query->the_post();
get_template_part( 'loop-portfolio' );
endwhile;
endif;
wp_reset_postdata();
} //END else is_tax()
} //END if ($theme_version == 'theme_version_fullscreen')
} //END if( is_page_template('template-portfolio-fullwidth.php')... ?>
<div id="page_nav" class="hide">
<?php next_posts_link(); ?>
</div><!-- END #page_nav -->