-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcq-2.php
116 lines (101 loc) · 2.98 KB
/
cq-2.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
<!-- Custom query (WP Query) -->
<?php
/**
* Template Name: Custom Query WP Query
*/
?>
<div>Custom Query Template</div>
<?php
$paged = get_query_var('paged') ? get_query_var('paged') : 1; //for paginate
$totalPost = array(15, 17, 19, 21, 23);
$posts_per_page = 2;
// $_p = new WP_Query(array(
// 'posts_per_page' => $posts_per_page,
// 'post__in' => $totalPost,
// 'orderby' => 'post__in',
// 'paged' => $paged,
// ));
// $_p = new WP_Query(array( //category wise post show
// 'paged' => $paged,
// 'posts_per_page' => $posts_per_page,
// 'category_name' => 'mango',
// 'orderby' => array('date' => 'ASC'),
// ));
// $_p = new WP_Query(array( //month, year & post status wise post show
// 'paged' => $paged,
// 'posts_per_page' => $posts_per_page,
// 'monthnum' => 2,
// 'year' => 2021,
// 'post_status' => 'publish',
// ));
// $_p = new WP_Query(array( //relationship
// 'paged' => $paged,
// 'posts_per_page' => $posts_per_page,
// 'orderby' => array('date' => 'ASC'),
// 'tax_query' => array(
// 'relation' => 'OR',
// array(
// 'taxonomy' => 'category',
// 'field' => 'slug',
// 'terms' => array('mango'),
// ),
// array(
// 'taxonomy' => 'post_tag',
// 'field' => 'slug',
// 'terms' => array('flower'),
// ),
// ),
// ));
// $_p = new WP_Query(array( //filter using post_format
// 'paged' => $paged,
// 'posts_per_page' => $posts_per_page,
// 'tax_query' => array(
// array(
// 'taxonomy' => 'post_format',
// 'field' => 'slug',
// 'terms' => array(
// 'post-format-audio',
// ),
// //'operator' => 'NOT IN' //uporer format bad diye baki gulo output dibe -- (operatior use korle)
// )
// )
// ));
// $_p = new WP_Query(array( //filter using single metabox value || used to show post in specfic page
// 'paged' => $paged,
// 'posts_per_page' => $posts_per_page,
// 'meta_key' => 'excerpt_is_featured',
// 'meta_value' => '1'
// ));
$_p = new WP_Query(array( //filter using multiple metabox value || used to show post in specfic page //https://rudrastyh.com/wordpress/meta_query.html
'paged' => $paged,
'posts_per_page' => $posts_per_page,
'meta_query' => array(
'relation' => 'AND', // both of below conditions must match
array(
'key' => 'excerpt_is_featured',
'value' => '1',
'compare' => '=',
),
array(
'key' => 'excerpt_is_homepage',
'value' => '1',
'compare' => '=',
),
),
));
while ($_p->have_posts()) {
$_p->the_post();
?>
<h2><a href="<?php the_permalink()?>"><?php the_title()?></a></h2>
<p><?php the_content()?></p>
<?php
}
wp_reset_query();
?>
<hr>
<?php
echo paginate_links(array(
'total' => $_p->max_num_pages,
'current' => $paged,
));
?>