-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-08 (shortcodes).php
60 lines (45 loc) · 1.28 KB
/
class-08 (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
<?php
/*
Plugin Name: Stock Toolkit
*/
//custom post
add_action( 'init', 'my_theme_custom_post' );
function my_theme_custom_post() {
register_post_type( 'Testimonial',
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' => __( 'Testimonial' )
),
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
'public' => false,
'show_ui' => true,
)
);
}
function post_list_shortcode($atts){
extract( shortcode_atts( array(
'count' => -1, // if -1 then all post will come
'type' => 'post',
), $atts) );
$q = new WP_Query(
array('posts_per_page' => $count,
'post_type' => $type
)
);
$list = '<ul>';
while($q->have_posts()) : $q->the_post();
$idd = get_the_ID();
$custom_field = get_post_meta($idd, 'custom_field', true);
$post_content = get_the_content();
$list .= '
<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>
';
endwhile;
$list.= '</ul>';
wp_reset_query();
return $list;
}
add_shortcode('post_list', 'post_list_shortcode');
*/
?>