query custom post type

Solutions on MaxInterview for query custom post type by the best coders in the world

showing results for - "query custom post type"
Samuel
02 Feb 2020
1  <?php    
2  	   $args = array(  
3      'post_type' => 'custom_type',
4      'post_status' => 'publish',
5      'posts_per_page' => 8, 
6      'orderby' => 'title', 
7      'order' => 'ASC', 
8          );
9
10  $loop = new WP_Query( $args ); 
11
12  while ( $loop->have_posts() ) : $loop->the_post(); 
13      print the_title(); 
14      the_excerpt(); 
15  endwhile;
16
17  wp_reset_postdata(); 
18  ?>
Antonin
20 Oct 2016
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
Dina
26 Jan 2020
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 );
Paola
15 Aug 2020
1//WordPress: Query a custom post type
2//For example, query all Case Study post types
3
4<?php query_posts('post_type=case_studies'); ?>
Jessy
19 Mar 2020
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 );
Mei
30 Feb 2020
1Custom Post Type Query Loop
queries leading to this page
query custom post typewordpress set query post typecustom post type support page attributeswordpress get the content of a custom post typemeta query of custom post type in wp queryget custom post type pagecustom post type custom fields contenthow to create a custom post type in wordpresscreate sub post types wordpresscustom post type categorieswordpress load post typecustom post type as pagewp query custom post type uiadding custom fields to a custom post typecustom post type wordpress generatecustom post type listget custom post typespost type wp querycustom post type titlecustom post type how to pull in wordpresspost typesx wordpresswordpress add cptwhile loop in custom post type post in wordpresssave new post type wpwordpress use in custom post typewp custom post type query varwordpress get custom post type in loopaccess custom post typewordpress create a new post typecpt loopwp query get category of custom post typecpt add contentquerying custom post types wordpresscustom posts types wordpress on dashboard menuwordpress cptcustom post type post attributescustom post type one add newcustom type post wordpresswp get post argscustom post type loopquery posts custom post typecustom postsql query to get custom field of wp postwp query all post for typehow to add post limited in custom post typeget custom post type by post namewp query get all item with custom post typewp add php in admin custom post type pagehow to use cpt ui to create a post and related postwhat is custom post type how to get custom post type custom post type idtags in custom post typetutorial custom post types wordpresshow to add custom post type in wordpresscustom post type addwordpress create custom post type with formswordpress post query custom post typemaking custom post type in wordpresswordpress query for custom post typehow create ustom post typpescustom post type pagecustom query with cptconsider post types as posts wordpressget all id of post type wpcustom post types wordpress codegenerate wp custom post typewordpress query postswordpress post type datahow to create different posts types in wordpresswordpress add new custom post typecustom post type tagswp create cutsom post typewp query custom post type taxonomycustom post type javascripthow to create custom post for text and image in wordpresswp create post typewp query custom postcustom post type definitionwp query custom post typewp get custom post type categorycustom post tyoequery to get all custom post type in wordpresswp get custom post type optionif is custom post type in querydevelop custom post typehow to search custom post type in wordpresscustom posts wordpress post typewp query post type 28 29how to get custome post type dataget custom post type postswhat is the links post type in wordpressget custom post type namewordpress post typescustom post type optionswordpress get custom post type termscustom post type in wordpress codehow to use wp query to display custom post type 24args 3d array 28 27post type 27 3d 3ehow to call custom post type in wordpresshow add new fields in custom post typewp 22should i use 22 custom post typewordpress query on customer post typewordpress custom querycustome post in wordpressadd custom post tylewp code custom post typeget custom field from post type id using wp query 2b wordpress phpmake custom post type support tags 2bwp query custom post type custom fieldcreate and fetch custom post type wordpresswp get posts custom post typeregistering custom post typesadd custom post types wordpresswhat is wordpress custom post typecustom post type codewp query get post typewordpress declare custom post typecode wordpress cptcustom post type using custom templatecontent of custom post type postwp query custom post type slugi can get posts for custom post type under wp queryturn on custom post typewordpress costum post typepost type add queryhow to print the custom post typecreating a custom post typewp query custom post type by category idwordpress wp query post typeadding texonomies to product post type in wordpresswp output posts custom post typephp wordpress create post of custom post typecustom post types how to show drafts in loopdisplayed custom post typewordpress with custom post typeshow post in custom post typewp query if notcustom post type creation in wordpressloop in custom post type relationship wordpresshow to register custom post type in wordpresscustomer custom post type for wordpress wordpress post typewp insert post custom post typewhat are custom post typeswp query custom post type categoriescreate sutom post typecustom post type functionwordpress adding custom post typecreating a custom post type wordpresswordpress loop custom post typewp query from specific post typewp get custom post typespost query to get custom post typehow to make a custom post typewp 2bcustom post typewordpress attachment post typedisplay all post type data in wordpresscreating custom post type wordpresswhat is a custom post typewordpress adding custom post type preferred typecustom post type loop by taxonomy query wpbeginnerwp query post type categorywordpress get custom post typecustom post typecustom post type samplecustom post type add fieldscustom post type page typepage attributes custom post typepost type createloop custom post type wordpresscustom post types pluginwp how to make post associated with other pos typecustom query for post by post type in wordpresswp code custom post type queryregister a custom post typewordpress custom post typecoustm post wpwhat is cpt in wordpressinsert post type php wpwordpress custom post querycustom post type for wordpressget query params custom post typescustom post type editor tutorialget custom post type wordpresscustom post type uiwhat is a wordpress custom post typesupdate post of custom post typecreate custom post type like postwp query custom post type loopcustom post types in wordpresswordpress post new to custom post typehow to use wp query to display custom post type in wordpresscustom post types and custom fieldscreate new custom post type wordpressform custom post typehow to register new post type in wordpresswordpress is main post type querycustom post tupeswhat is custome post type in wordpresscheck custom post typepost type wordpadd custom post type supportcreate custom post type wordpress with optionscusom post type wordpresscustom post type as a pagehow to create a custom post in wordpresshow to query custom type post in wordpresswrodpress query custom postwp query custom post type contentwordpress wp query custom post typeadd custom post type for woocommerce account get vcustom post type wordpresswp query post by idwp query custom post type loopwordpress php query for custom post typeadd all features in custom post in wordpressi want to make form on admin side custom post type form in wordpresssource type wordpressadd met for custom post typewordpress query get custom post typehow to find a custom post wordpresswp add view to post typeget terms custom post typehow to create a custom post page in wordpresswpml custom post typeadd a meta to a custom post typeget custom post by typecustom post type loop wordpresscustom post type 2b wordpresswordpress how to query post typeswp query get post typespost types wordpresscustom post type plugincreate custom post type wordpressget custom post type fieldswp query get custom post typewordpress query custom post typecustom post type wordpresswordpress add new post typequery custom post type wordpresssql query custom post typewp query custom post typehow to get custom field in custom post typecreate and use custom post type wordpressis post type 3d custom wordpresscustom query for post with loopget results sql wordpress custom post typecustom post type page namecustom post type with custom field codequery custom post type wpwp query for custom post typemake custom post type in wordpressgenerate custom post typewp query my custom post typehow to display custom post type data in wordpresscustom post type post for a specific post wordpressquery post based on status wordpresscustom post types tutorialwordpess custom post typecustom post type with custom field custom post type taxonomy query wpbeginnerwordpress query post type custom fieldwordpress custom pot type loopcreate page type from post typepost type in wordpresswp query display all custom post typewordpress custom post type loopwordpress how to query custom postsget custom post type in wordpresshow to add new custom post type in wordpresspost type e custom post typecustom post type page formatget post from custom post typecustom post type wp querywp create custom post typewordpress custom post type creationhow to make custom page post type custom post tyecustom post view wordpresssql custom post typewordpress query set post typehow to create custom post type plugincustom post type categories functionswordpress search query custom post typecreating a custom post type manuallypost type page wordpresshow to store a single posttype in a pluginterms of custom post tyoewordpress functions php custom post typecustom post type archivecreate new post type wordpresswordpress settings for custom post type post templatepopular post custom post type wordpresshow to make a custom post type in wordpresscustom post type wordpress phppost type article wordpresswordpress admin custom post typewordpress make custom post typewordpress custom psot typehow to get custom post type data in wordpresswp query custom post type category inget custom post type queryi want to make form on admin side custom post type in wordpressbasic custom post type codewordpress php custom post type querywp new custom post typewordpress cutsom post typehow to create post type custom post type plugin codeloop through all custom post type wordpressget post using custom post typehow to create custom post types in wordpresscustom post type in wordpress exampleadd custom post type to posts queryhow to query custom post type in wordpresswordpress custom query for custom post typequery set post type wordpresscustom post type attributesquery for both custom post type and categorycustom post types e custom post fieldshow to create custom post type in wordpresswordpress add user using a custom post typwp query custom post type data in wordpress default postadd custom post type to custom post type wp codewordpress sql query custom post typeget detials in custom post type in wordpressget all posts of a custom post type in loopcreating new post typeget query post in wordpresswordpress custom post type query pagewordpress custom post type functions phpwp query get all post type by userwp custom query postwp custom post type phpwordpress custom post type post for userswordpress add post typesblog post custom loop wp querypost to custom post typeswordpress insert post of custom post typecreate a custom post type wordpress phpwp query to get custom post type listwordpress custom post type attributescreate a custom post type page in wordpresswhat are the fields that wp generate creates for custom post typewp query for custom post typewhere i can find custom post type code in wordpressadd cpthow to loop custom post typesdisplay custom post type contentcustom blog loop wp querywordpress query post types array between customwrite query based on custom post typecustom fields for custom post typespost in custom querynew cpt wordpresshow to use wp query to display custom post type current postscustom post type create in wordpresswordpress query meta querycustom post type pagedadd custom post type wordpresswhat are the different methods you can use to create a custom post type 3fhow to post a post type in wordpresswp query custom postcustom post type code in wordpressadd custom field using post type supportreister custom post typewordpress woocommerce cpt servicespost type custom functionscustom post type icon wordpressadd custom fields to custom post typewordpress php query custom post typewordpress display list of posts including custom post typeswp custom post typeswp query specific post typecreate custom post type acfdwordpress generate custom post typeadd custom post type from front wordpresscustom post type with custom fields wordpresswp query for post typewordpress get categories of custom post typewordpress post type by code tutorialwordpress loop for custom post typeadd custom fields in custom post typewhat is post type in wordpresswordpress custom post types how to make custom post type in wordpresswordpress post types explainedregister custom post typecustom query custom post typeget custom post typecustom post type code samplehow to create custom post typeinsert custom code in cpt page custom post type wordpress exampleadd custom field in post typewp query all posts of post typeswp create a custom post type add custom post type in wordpresswp query post typecreate custome post type wordpresscustom post type 5cwp query custom post typehow to use custom post type in wordpresswordpress query post type custom field valuecustom post type loop with post type query wpbeginnercustom content type in wordpresshow to get custom post type tagswordpress get custom posts in while loopwordpress 3fpost type querycustom post type detail pagewp query post types all itemswordpress custom post type query with wp querycustom post types tutorialscustom post type within a custom post typecreate a custom post type in wordpresswp query fetch post create a custom post type wordpresswordpress modify main query custom post typecreate custom field in post typeget post from custom field type queryhow many methods to get the all categories of the custom post type in wordpress phpquery wp database to return custom post type by idwordpress add custom post typesadd custom field to custom post typeshow custom post type postscustom post types 2b wordpresswordpress add post typecreate post type in wordpress codeall custom post type page wordpressdisplaying custom post typeswordpress tag custom post type with another custom post typewp get custom post typehow to create custom form in post typecustom post wordpressadd custom page on custom post typepopular post query custom post type wordpresswordpress loop post typecreate custome post typewordpress custom post type explainedwordpress custom post type how tocalling custom post type on home pagewpdb query custom post typewp query to display custom post typecreate custom post type in wordpresspost in wordpress ids wpquerycustom post type callingwhat is a custom post type wordpresscustom post type parameterswordpress get custom post type loopget post with custom post type wordpresswp get custom post types by categoryset text for not found posts for custom post type in wordpresssimple custom post typecustom post types optionscustom post type have postswordpress create custom post typepost type custom wp query custom post type categorywordpress custom post type onlmake a page for a post typewordpress show custom post type to userwp query get custom post type categorieshow to use wp query to display custom post typemaking custom post typeswp should i use custom post type get posts custom post typeget post custom post type wordpressset wp query different post typewp custom post type uihow to display a custom post type in wordpresswp query get post by post typecustom post type de wordpresswordpress code that returns post type post and pageshow custom post type custom post type post loopcustom post type tutorialcustom post type insert postwp get custom post type pagedcustom post type pageswordpress custom insert query for custom post type 24query get post typecustom post type htmlquery post type wordpresscustom post type create codequery to get all custom post type posts wordpresscustom post type query by categorywhat is custom post types in wordpresshow to get custom post type field valuecustom post type loopscustom post type custom fieldsposted on custom post typepost type and post id wp querywp query custom post type custom taxonomyadd custom post typefunction php add custom post typecuston post typewp query get custom post typecpt in cpt wordpresspost type pagecpt querywordpress query of post typecustom post type displaycustom query al custom post typecreate custom post typecustom post type wpcustom post custom fieldwordpress query all custom post typescustom post type and single postwp query for custom post typeswordpress custom content typequery post based on field wordpresswordpress codex cptwhat is a custom post type in wordpress 3f how and why would you use a custom post type 3fset up a custom post type in wordpresscustom post type in wordpress example of when we create onepost type query wordpresswp query post type post including cptwp get custom post type categorieshow to create post type on wordpress by codeloop through custom post typeadd custom field in custom post typeview custom post type wordpresscustom post tytpe pagehow to add new post type wordpresscustom post type custom attributeswordpress default post typeswp screen custom post typeset the post custom post typecustom post types wordpressget custom post type post termspopular post custom posttype worpdresswp get posts custom post typecustom post type category querywp add custom post typequery all of custom post type wordpresswordpress query post custom typewp query get the popular for custom post typewordpress get loop custom post typewordpress query by post typequery all custom post type in wordpresswordpress custome post typefetch custom post details in wordpresssimple custom post type in wordpresswp query category custom post typewordpress custom post wueryadd wordpress post typeget results from custom post type wordpress custom post type registrationget the title custom post typecustom post type classwp query custom post type statusget posts custom post typesample custom post typewordpress get custom post type datawp post type 28 29wordpress custom post type tutorialcustom post type query loop wordpresswordpress get custom post type postswp query with custom post typesadd custom post type in wordpress postswp custom post typewordpress create new post typequery a custom post in wordpresswordpress how to set a post typeget custom posty type querycreate a post type wordpresscustom post type detail apge loop for custom post type wordpresswhere i can find post type source code in wordpresswordpress meta queryadd a custom post type wordpresspost type options wordpresscreating a post type inhtml in custom posttypetags on custom post typepost type querywordpress query post typewordpress admin custom post entry template plugincustom post type custom variableset custom post type post linkcustom post typcustom post type singlethachpham custom post typeget all of custom post typecustom field in custom post typecreate customer post type in wordpressget the custom post type in wordpressadding custom post type wordpresscustom post type query loophow to make custom post type pagewp custom post type query varscustom post type usercustom html in posttypecustom post type options wpwp query custom post type categorywp query custom post type allinsert custom post in a page wordpresscustom post type with wordpresswordpress create a custom post typewp query all custom post typelink custom post types to a templateloop through custom post type wordpresswp query get custom post typecustom post typeshow to use query var for custom post typedisplay custom post typecustom post type with custom fieldscustom post type adding morewordpress rest api get custom post typewp query query id of custom post typeadd new custom post type wordpresswordpress query custom post type by categoryadd custom element in posttype list pagecustom post type link wordpress dashboardwordpress custom sql query post typecreate content type wordpress post typethe loop custom wordpress post typecall custom post type in wordpresscheck where is custom post file is create in wordpresscustom post type supportwp query custom post type searchwp insert custom post typecreate post type in wordpressget list post type query wordpresscustom post type queryquery var for an custom post typequery custom post by custom fieldscustom post type in wordpress plugincustom post type check custom post type options 27date query 27 3d 3e array 28wp query custom post type by slugwordpress custom post typewordpress create post typesadd code to custom post type wordpresscreate post type wordpresshow to get custom post type 27s tagswordpress custom post type loop with categoriescpt wordpresscreate post type query wordpresswordpress how to create custom post typehow to add a post type in wordpresscustomk post typewordpress create the custom post typeget the custom post type categorywordpress custom post loopadd new type wordpresscustom post type post urlcreate post typehow to create a custom post type for wordpressget custom post type wp querywordpress loop query custom post typecheck where is custom post file is create in wordpresswordpress custom post type codecustom fields and post typesfor each custom post typewordpress create page types for postcustom post types on different pageis single custom post typeset parameter for post display wordpresssimple post typewp query post type customnpost type wordpresswp query for a page with parent slugcustom post types wptutscustome post typecustom post type pagecontent that can be added to custom post types wpcustom post type query in wordpresswordpress custom post type phpwp query post typewp query get single custom postfunction custom postscustom post in wordpresscustom post types and custom fields wordpress get custom post types of other blogcustom post type wordpress demowordpress org add custom post typedisplay custom post type in wordpresshot to give public true on custom post typewordpress query to get posts of custom posttypewordpress query post typecreate custom post type template wordpressget pgination for custom post typewp query post typescustom post type termscustom post type show custom fieldswordpress custom section like posthow to use cpt uiwhat is custom post type in wordpresswordpress custom post type querycustom post type in wordpresscreating a custom post type for user add data to custom post manually phphow to call custom post type in wordpress codewordpress create page for custom postcustom post type query wordpresswp is custom post typepage post type wordpresscreating custom post types in wordpressget results wordpress custom post typecustom post type loop wordpresswordpress insert custom post type how to load a post type on a pagehow to add a custom post type in wordpresscostom post typeuse custom post type info on pagecustom posts type creating acustom post typecustom post type createhow to display custom post typecreate new post for a custom post typecreate a custom post type with a functiongetting custom post typecustom post type post perpagewp query custom post type idcreating a basic custom post typenew wp query custom post typeget custom post type post based on namewordpress add post to custom post typecustom post type get custom post type to pagewordpress create the user at the time of custom post type creationget custom post typestandar page for custom post type wordpresswordpress custom post type structure examplewordpress custom post type category loopwordpres custom post typehow create custom post type in wordpresswp post types wp querywordpress add custom post typ ehow to create custom post type 3fwordpress post type querywp query custom post valuewhat can you put in custom posttype custom post type fieldwp query post typewordpress add custom post typequery custom post type