-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWP_Query.php
More file actions
82 lines (64 loc) · 2.01 KB
/
WP_Query.php
File metadata and controls
82 lines (64 loc) · 2.01 KB
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
<?php
// method by LWHH
?>
<div class="posts text-center">
<?php
$paged = get_query_var( "paged" ) ? get_query_var( "paged" ) : 1;
$posts_per_page = 3;
$post_ids = array( 58, 68, 81, 43, 56, 70, 38 );
$_p = new WP_Query( array(
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'featured',
'value' => '1',
'compare' => '='
),
array(
'key' => 'homepage',
'value' => '1',
'compare' => '='
)
)
) );
while ( $_p->have_posts() ) {
$_p->the_post();
?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></h2></a>
<?php
}
wp_reset_query();
// Pagination for posts ?>
<div class="container post-pagination">
<div class="row">
<div class="col-md-12">
<?php
echo paginate_links( array(
'total' => $_p->max_num_pages,
'current' => $paged,
'prev_next' => false,
) );
?>
</div>
</div>
</div>
</div>
<?php
// easy method
$skills = new WP_Query( array(
'post_type' => 'ieatwp-skills',
'posts_per_page' => 5,
'order' => 'ASC',
'category_name' => 'category1, category_2'
) );?>
<?php while($skills->have_posts()) : $skills->the_post(); ?>
<h4> <?php the_title(); ?> </h4>
<div class="progress">
<div class="progress-bar progress-bar-striped active <?php echo get_post_meta(get_the_ID(), 'skill-percentage-class', true); ?>" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100">
<?php echo get_post_meta(get_the_ID(), 'skill_percentage', true); ?>
</div>
</div>
<?php endwhile;
wp_reset_postdata(); // we can use wp_reset_query(); too