SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | ||
3 | $args = get_sticky_query_args(); | |
4 | extract( $args ); | |
5 | ||
6 | /* loop for sticky posts */ | |
7 | if ( !empty( $sticky_posts ) ) { | |
8 | ||
9 | $args_sticky_loop = array( | |
10 | 'posts_per_page' => $sticky_count, | |
11 | 'post__in' => $sticky_posts, | |
12 | 'orderby' => 'post__in', | |
13 | 'ignore_sticky_posts' => 1, | |
14 | 'no_found_rows' => true, | |
15 | 'cache_results' => false | |
16 | ); | |
17 | ||
18 | $sticky_query = new WP_Query( $args_sticky_loop ); | |
19 | ||
20 | if ( $sticky_query->have_posts() ) : | |
21 | /* start of sticky loop */ | |
22 | while ( $sticky_query->have_posts() ) : $sticky_query->the_post(); ?> | |
23 | ||
24 | <?php get_template_part( 'content', get_post_format() ); ?> | |
25 | ||
26 | <?php | |
27 | endwhile; // end of sticky loop | |
28 | wp_reset_postdata(); | |
29 | ||
30 | endif; | |
31 | ||
32 | } | |
33 | ?> | |
34 | <?php | |
35 | $show_loop = true; | |
36 | ||
37 | /* default args for normal posts loop */ | |
38 | ||
39 | $args_loop = array( | |
40 | - | 'post_type' => array('post'), |
40 | + | 'post_type' => array('post', 'careers-post'), |
41 | - | 'category__in' => array(57), |
41 | + | 'category__in' => $page_categories, |
42 | 'posts_per_page' => $posts_per_page, | |
43 | 'paged' => $paged | |
44 | ); | |
45 | ||
46 | /* there are stickies */ | |
47 | if ( !empty( $all_stickies ) ) { | |
48 | ||
49 | $args_loop['ignore_sticky_posts'] = 1; | |
50 | $args_loop['post__not_in'] = $all_stickies; | |
51 | ||
52 | /* sticky and/or normal posts on current page */ | |
53 | if ( $paged <= $mixed_page ) { | |
54 | $args_loop['posts_per_page'] = $sticky_count; | |
55 | ||
56 | if ( $paged == $mixed_page ) { | |
57 | $args_loop['paged'] = 1; | |
58 | $args_loop['posts_per_page'] = $mixed_posts_per_page; | |
59 | } | |
60 | ||
61 | } | |
62 | ||
63 | /* only normal posts on current page */ | |
64 | if ( $paged > $mixed_page ) { | |
65 | ||
66 | // calculate offset | |
67 | $posts_to_skip = $posts_per_page - $mixed_posts_per_page; | |
68 | $offset = ( ( $paged - $mixed_page ) * $posts_per_page ) - $posts_to_skip; | |
69 | //echo $offset; | |
70 | $args_loop['offset'] = $offset; | |
71 | ||
72 | } | |
73 | ||
74 | } | |
75 | ||
76 | query_posts($args_loop); | |
77 | ||
78 | /* adjust the max_num_pages variable for pagination functions (when there are sticky posts) */ | |
79 | if(!empty($all_stickies)) { | |
80 | $found_posts = (isset($wp_query->found_posts) && $wp_query->found_posts) ? (int) $wp_query->found_posts : 0; | |
81 | $total_pages = ceil( (count($all_stickies) + $found_posts) / $posts_per_page); | |
82 | $wp_query->max_num_pages = $total_pages; | |
83 | } | |
84 | ||
85 | /* check if only sticky posts on current page */ | |
86 | $show_loop = (!empty( $all_stickies ) && ( $paged < $mixed_page ) ) ? false : true; | |
87 | ||
88 | if ( $show_loop ) : | |
89 | ||
90 | /* check if there are posts */ | |
91 | if ( have_posts() ) : ?> | |
92 | ||
93 | <!-- top pagination functions here --> | |
94 | ||
95 | <?php /* Start the Loop */ ?> | |
96 | <?php while ( have_posts() ) : the_post(); ?> | |
97 | <?php get_template_part( 'content', get_post_format() ); ?> | |
98 | <?php endwhile; ?> | |
99 | <?php /* End ot the Loop */ ?> | |
100 | ||
101 | <!-- bottom pagination functions here --> | |
102 | <?php twentytwelve_content_nav( 'nav-below' ); ?> | |
103 | <?php else : ?> | |
104 | ||
105 | <article id="post-0" class="post no-results not-found"> | |
106 | ||
107 | <header class="entry-header"> | |
108 | <h1 class="entry-title"><?php _e( 'No posts to display', 'twentytwelve' ); ?></h1> | |
109 | </header> | |
110 | ||
111 | </article><!-- #post-0 --> | |
112 | ||
113 | <?php endif; // end if have_posts() check ?> | |
114 | <?php endif; // end if $show_loop check ?> | |
115 | ||
116 | <?php if(!$show_loop) : ?> | |
117 | ||
118 | <!-- bottom pagination functions here--> | |
119 | <?php twentytwelve_content_nav( 'nav-below' ); ?> | |
120 | ||
121 | <?php endif; ?> |