-
Notifications
You must be signed in to change notification settings - Fork 2
/
shortcodes.php
executable file
·67 lines (62 loc) · 1.46 KB
/
shortcodes.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
<?php // Add Shortcode
function wpcc_shortcode( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'count' => '-1',
'card_group' => '',
'layout' => NULL,
),
$atts,
'wpcc'
);
// Use Card_Group *if* we have one
if ($atts['card_group'] != ''){
$wpcc_query = new WP_Query( array (
'post_type' => 'card',
'posts_per_page' => $atts['count'],
'orderby' => 'menu_order',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'card_group',
'field' => 'slug',
'terms' => $atts['card_group'],
),
),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'wpcc_unlisted',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'wpcc_unlisted',
'value' => '0',
'compare' => '==',
),
),
) );
}else{
$wpcc_query = new WP_Query( array (
'post_type' => 'card',
'posts_per_page' => $atts['count'],
'orderby' => 'menu_order',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'wpcc_unlisted',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'wpcc_unlisted',
'value' => '0',
'compare' => '==',
),
),
) );
}
return wpcc_card_display($wpcc_query,$atts['layout']);
}
add_shortcode( 'wpcc', 'wpcc_shortcode' );