-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtop.stories.php
95 lines (92 loc) · 3.53 KB
/
top.stories.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
<?php
/**
* Template Name: Top News Template.
*
*/
$bits = explode( '/', rtrim($_SERVER['REQUEST_URI'], '/') );
$section = array_pop( $bits );
switch( $section ) {
case 'section-plugins' :
$category = explode( '-', $section );
$cat = get_category_by_slug( $category[1] )->term_id;
$args = array( 'posts_per_page' => 10, 'meta_key' => 'post_views_count', 'orderby' => 'post_views_count', 'order' => 'DESC', 'cat' => $cat );
break;
case 'section-themes' :
$category = explode( '-', $section );
$cat = get_category_by_slug( $category[1] )->term_id;
$args = array( 'posts_per_page' => 10, 'meta_key' => 'post_views_count', 'orderby' => 'post_views_count', 'order' => 'DESC', 'cat' => $cat );
break;
case 'section-buddypress' :
$category = explode( '-', $section );
$cat = get_category_by_slug( $category[1] )->term_id;
$args = array( 'posts_per_page' => 10, 'meta_key' => 'post_views_count', 'orderby' => 'post_views_count', 'order' => 'DESC', 'cat' => $cat );
break;
}
?>
<div class="panel">
<div class="panel-heading" style="background-color:#111;color:#fff;">Top Stories</div>
<div class="panel-body">
<?php
$loop = new WP_Query( $args ); $i = 0;
while ( $loop->have_posts() ) : $loop->the_post();
$i++;
?>
<?php if( $i == 1 ) { ?>
<div class="row">
<div class="col-md-8">
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<button data-toggle="modal" data-target="#myModal" data-url="<?php the_permalink(); ?>" data-title="<?php the_title(); ?>" class="post_link btn btn-default">More</button>
</div>
<div id="featured_image" class="col col-sm-4">
<?php echo get_the_post_thumbnail($post->ID, 'image-full', array('class' => 'img-responsive')); ?>
</div>
</div>
<hr>
<?php } elseif( $i == 3 ) { ?>
<div class="row">
<div class="col-md-6">
<a class="post_link" data-toggle="modal" data-target="#myModal" data-url="<?php the_permalink(); ?>" data-title="<?php the_title(); ?>" href="#"><?php echo get_the_post_thumbnail($post->ID, 'image-full', array('class' => 'img-responsive featured')); ?></a>
</div>
<div class="col-md-6">
<h1><?php the_title(); ?></h1>
</div>
</div>
<hr>
<?php } else { ?>
<h2><?php the_title(); ?></h2>
<?php echo get_the_post_thumbnail($post->ID, array(100,100), array('class' => 'img-responsive pull-right in-post')); ?>
<?php the_excerpt(); ?>
<button data-toggle="modal" data-target="#myModal" data-url="<?php the_permalink(); ?>" data-title="<?php the_title(); ?>" class="post_link btn btn-default">More</button>
<hr>
<?php } ?>
<?php endwhile; ?>
<h4 class="related_header">Other News</h4>
<?php
$args = array( 'posts_per_page' => 5, 'category__not_in' => $cat, 'post__not_in' => array($post->ID) );
$loop = new WP_Query( $args ); $i = 0;
while ( $loop->have_posts() ) : $loop->the_post();
$i++;
?>
<div class="col-md-6 related">
<div class="col-md-4">
<a class="post_link" data-toggle="modal" data-target="#myModal" data-url="<?php the_permalink(); ?>" data-title="<?php the_title(); ?>" href="#">
<?php the_post_thumbnail( array(150,100) ); ?>
</a>
</div>
<div class="col-md-8">
<a class="post_link" data-toggle="modal" data-target="#myModal" data-url="<?php the_permalink(); ?>" data-title="<?php the_title(); ?>" href="#">
<h4><?php the_title(); ?></h4>
</a>
<div class="meta"><?php USACore::_list_cats( $post->ID ); ?> <small><em><?php echo get_the_date(); ?></em></small></div>
</div>
</div>
<?php if( $i%2 == 0 ) { ?>
<hr class="related_sep">
<?php } ?>
<?php
endwhile;
wp_reset_query();
?>
</div>
</div>