1<?php
2$args = array(
3 'post_type' => 'product',
4 'posts_per_page' => 10,
5);
6$loop = new WP_Query($args);
7while ( $loop->have_posts() ) {
8 $loop->the_post();
9 ?>
10 <div class="entry-content">
11 <?php the_title(); ?>
12 <?php the_content(); ?>
13 </div>
14 <?php
15}
16
1/*
2* Creating a function to create our CPT
3*/
4
5function custom_post_type() {
6
7// Set UI labels for Custom Post Type
8 $labels = array(
9 'name' => _x( 'Movies', 'Post Type General Name', 'twentytwenty' ),
10 'singular_name' => _x( 'Movie', 'Post Type Singular Name', 'twentytwenty' ),
11 'menu_name' => __( 'Movies', 'twentytwenty' ),
12 'parent_item_colon' => __( 'Parent Movie', 'twentytwenty' ),
13 'all_items' => __( 'All Movies', 'twentytwenty' ),
14 'view_item' => __( 'View Movie', 'twentytwenty' ),
15 'add_new_item' => __( 'Add New Movie', 'twentytwenty' ),
16 'add_new' => __( 'Add New', 'twentytwenty' ),
17 'edit_item' => __( 'Edit Movie', 'twentytwenty' ),
18 'update_item' => __( 'Update Movie', 'twentytwenty' ),
19 'search_items' => __( 'Search Movie', 'twentytwenty' ),
20 'not_found' => __( 'Not Found', 'twentytwenty' ),
21 'not_found_in_trash' => __( 'Not found in Trash', 'twentytwenty' ),
22 );
23
24// Set other options for Custom Post Type
25
26 $args = array(
27 'label' => __( 'movies', 'twentytwenty' ),
28 'description' => __( 'Movie news and reviews', 'twentytwenty' ),
29 'labels' => $labels,
30 // Features this CPT supports in Post Editor
31 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
32 // You can associate this CPT with a taxonomy or custom taxonomy.
33 'taxonomies' => array( 'genres' ),
34 /* A hierarchical CPT is like Pages and can have
35 * Parent and child items. A non-hierarchical CPT
36 * is like Posts.
37 */
38 'hierarchical' => false,
39 'public' => true,
40 'show_ui' => true,
41 'show_in_menu' => true,
42 'show_in_nav_menus' => true,
43 'show_in_admin_bar' => true,
44 'menu_position' => 5,
45 'can_export' => true,
46 'has_archive' => true,
47 'exclude_from_search' => false,
48 'publicly_queryable' => true,
49 'capability_type' => 'post',
50 'show_in_rest' => true,
51
52 );
53
54 // Registering your Custom Post Type
55 register_post_type( 'movies', $args );
56
57}
58
59/* Hook into the 'init' action so that the function
60* Containing our post type registration is not
61* unnecessarily executed.
62*/
63
64add_action( 'init', 'custom_post_type', 0 );
1$args = array(
2 'post_status' => 'publish',
3 'posts_per_page' => 5,
4
5 );
6
7 $loop = new WP_Query( $args );
8
9 while ( $loop->have_posts() ) : $loop->the_post();
10 the_title();
11 the_excerpt();
12 endwhile;
1.wp-block-code {
2 border: 0;
3 padding: 0;
4}
5
6.wp-block-code > div {
7 overflow: auto;
8}
9
10.hljs {
11 box-sizing: border-box;
12}
13
14.hljs.shcb-code-table {
15 display: table;
16 width: 100%;
17}
18
19.hljs.shcb-code-table > .shcb-loc {
20 color: inherit;
21 display: table-row;
22 width: 100%;
23}
24
25.hljs.shcb-code-table .shcb-loc > span {
26 display: table-cell;
27}
28
29.wp-block-code code.hljs:not(.shcb-wrap-lines) {
30 white-space: pre;
31}
32
33.wp-block-code code.hljs.shcb-wrap-lines {
34 white-space: pre-wrap;
35}
36
37.hljs.shcb-line-numbers {
38 border-spacing: 0;
39 counter-reset: line;
40}
41
42.hljs.shcb-line-numbers > .shcb-loc {
43 counter-increment: line;
44}
45
46.hljs.shcb-line-numbers .shcb-loc > span {
47 padding-left: 0.75em;
48}
49
50.hljs.shcb-line-numbers .shcb-loc::before {
51 border-right: 1px solid #ddd;
52 content: counter(line);
53 display: table-cell;
54 padding: 0 0.75em;
55 text-align: right;
56 -webkit-user-select: none;
57 -moz-user-select: none;
58 -ms-user-select: none;
59 user-select: none;
60 white-space: nowrap;
61 width: 1%;
62}
63// Register Custom Post Type - Workshop
64function kp_workshops() {
65
66 $args = array(
67 'label' =>; __( 'Workshop', 'kp_workshops' ),
68 'description' =>; __( 'Workshop listing', 'kp_workshops' ),
69 'labels' =>; $labels,
70 'supports' =>; array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'custom-fields' ),
71 'taxonomies' =>; array( 'category' ),
72 'hierarchical' =>; false,
73 'public' =>; true,
74 'show_ui' =>; true,
75 'show_in_menu' =>; true,
76 'menu_position' =>; 20,
77 'menu_icon' =>; 'dashicons-welcome-learn-more',
78 'show_in_admin_bar' =>; true,
79 'show_in_nav_menus' =>; true,
80 'can_export' =>; true,
81 'has_archive' =>; true,
82 'exclude_from_search' =>; false,
83 'publicly_queryable' =>; true,
84 'capability_type' =>; 'page',
85 'show_in_rest' =>; true,
86 );
87
88 register_post_type( 'workshops', $args );
89
90}
91add_action( 'init', 'kp_workshops', 0 );
1// Register Custom Post Type
2function custom_post_type() {
3
4 $labels = array(
5 'name' => _x( 'Post Types', 'Post Type General Name', 'text_domain' ),
6 'singular_name' => _x( 'Post Type', 'Post Type Singular Name', 'text_domain' ),
7 'menu_name' => __( 'Post Types', 'text_domain' ),
8 'name_admin_bar' => __( 'Post Type', 'text_domain' ),
9 'archives' => __( 'Item Archives', 'text_domain' ),
10 'attributes' => __( 'Item Attributes', 'text_domain' ),
11 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
12 'all_items' => __( 'All Items', 'text_domain' ),
13 'add_new_item' => __( 'Add New Item', 'text_domain' ),
14 'add_new' => __( 'Add New', 'text_domain' ),
15 'new_item' => __( 'New Item', 'text_domain' ),
16 'edit_item' => __( 'Edit Item', 'text_domain' ),
17 'update_item' => __( 'Update Item', 'text_domain' ),
18 'view_item' => __( 'View Item', 'text_domain' ),
19 'view_items' => __( 'View Items', 'text_domain' ),
20 'search_items' => __( 'Search Item', 'text_domain' ),
21 'not_found' => __( 'Not found', 'text_domain' ),
22 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
23 'featured_image' => __( 'Featured Image', 'text_domain' ),
24 'set_featured_image' => __( 'Set featured image', 'text_domain' ),
25 'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
26 'use_featured_image' => __( 'Use as featured image', 'text_domain' ),
27 'insert_into_item' => __( 'Insert into item', 'text_domain' ),
28 'uploaded_to_this_item' => __( 'Uploaded to this item', 'text_domain' ),
29 'items_list' => __( 'Items list', 'text_domain' ),
30 'items_list_navigation' => __( 'Items list navigation', 'text_domain' ),
31 'filter_items_list' => __( 'Filter items list', 'text_domain' ),
32 );
33 $args = array(
34 'label' => __( 'Post Type', 'text_domain' ),
35 'description' => __( 'Post Type Description', 'text_domain' ),
36 'labels' => $labels,
37 'supports' => false,
38 'taxonomies' => array( 'category', 'post_tag' ),
39 'hierarchical' => false,
40 'public' => true,
41 'show_ui' => true,
42 'show_in_menu' => true,
43 'menu_position' => 5,
44 'show_in_admin_bar' => true,
45 'show_in_nav_menus' => true,
46 'can_export' => true,
47 'has_archive' => true,
48 'exclude_from_search' => false,
49 'publicly_queryable' => true,
50 'capability_type' => 'page',
51 );
52 register_post_type( 'post_type', $args );
53
54}
55add_action( 'init', 'custom_post_type', 0 );