-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault_setup.php
More file actions
54 lines (45 loc) · 1.08 KB
/
Copy pathdefault_setup.php
File metadata and controls
54 lines (45 loc) · 1.08 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
<?php
/**
* Setup Default CPT.
*
* File: php/name.php
*/
$atts = shortcode_atts(
array(
'number' => -1,
'orderby' => 'menu_order',
'category' => '',
),
$atts,
'shortcode_slug'
); // Change 'shortcode_slug' as specified in FUNCTIONS.PHP.
$numberposts = $atts['number'];
$order_by = $atts['orderby'];
$category = $atts['category'];
// args.
$args = array(
'post_type' => 'my_post_type_slug', // Change 'my_post_type_slug' to your Custom Post Type slug.
'posts_per_page' => $numberposts,
'post_status' => 'publish',
'orderby' => $order_by,
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'my_category_slug', // Change 'my_category_slug' to your Custom Taxonomy slug.
'field' => 'slug',
'terms' => $category,
'operator' => 'AND',
),
),
);
$my_post_type = new WP_Query( $args );
if ( $my_post_type->have_posts() ) :
while ( $my_post_type->have_posts() ) :
$my_post_type->the_post(); ?>
<p>Hello world!</p>
<?php
endwhile;
wp_reset_postdata();
else :
_e( 'Woops! Nothing found!', 'hoolite' );
endif;