NOTES: Custom Post Type – Queries / Builders /

++++++++++++++++++++++===========++++++=======++++++++++++++++

videos.wpbeginner.com/

Displaying Custom Post Type Using Default Archive Template

First, you can simply go to Appearance » Menus and add a custom link to your menu.
This custom link is the link to your custom post type.

If you are using SEO friendly permalinks then your CPT’s URL will most likely be something like this:

example.com/movies

If you are not using SEO friendly permalinks, then your custom post type URL will be something like this:

example.com/?post_type=movies

it will display your custom post type archive page using the

archive.php template file in your theme.

CREATE NEW TEMPLATE TO DISPLAY:::

Using Custom Templates for CPT Archives and Single Entries
If you don’t like the appearance of the archive page for your custom post type, then you can use dedicated template for custom post type archive.

To do that all you need to do is create a new file in your theme directory and name it archive-movies.php. Replace movies with the name of your custom post type.

For getting started, you can copy the contents of your theme’s archive.php file into archive-movies.php template and then start modifying it to meet your needs.

Now whenever the archive page for your custom post type is accessed, this template will be used to display it.

Similarly, you can also create a custom template for your post type’s single entry display. To do that you need to create single-movies.php in your theme directory. Don’t forget to replace movies with the name of your custom post type.

You can get started by copying the contents of your theme’s single.php template into single-movies.php template and then start modifying it to meet your needs.

DISPLAY AMONG REGULAR POSTS:::::

then you can do so by adding this code into your theme’s functions.php file or a site-specific plugin:

[php] add_action( ‘pre_get_posts’, ‘add_my_post_types_to_query’ );

function add_my_post_types_to_query( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( ‘post_type’, array( ‘post’, ‘movies’ ) );
return $query;
}
[/php] Don’t forget to replace movies with your custom post type.

QUERY IN LOOP:::::::

Querying Custom Post Types
If you are familiar with the coding and would like to run loop queries in your templates, then here is how to do that (Related: What is a Loop?).

By querying the database, you can retrieve items from a custom post type.

[php] <?php
$args = array( ‘post_type’ => ‘movies’, ‘posts_per_page’ => 10 );
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( ‘Sorry, no posts matched your criteria.’ ); ?></p>
<?php endif; ?>
[/php] In this code, first, we have defined the post type and posts per page in the arguments for our new WP_Query class.

After that, we ran our query, retrieved the posts and displayed them inside the loop.

USER WIDGET TO DISPLAY::::::

Displaying Custom Post Types in Widgets
You will notice that there is a default widget in WordPress to display recent posts, but it does not allow you to choose a custom post type.

What if you wanted to display the latest entries from your newly created post type in a widget? There is an easy way to do this.

First thing you need to do is install and activate the Ultimate Posts Widget plugin. Upon activation, simply go to Appearance » Widgets and drag and drop the Ultimate Posts widget to a sidebar.

Ultimate posts widget

This powerful widget will allow you to show recent posts from any post types. You can also display post excerpts with a read more link or even show a featured image next to post title.

Configure the widget by selecting the options you want and by selecting your custom post type. After that save your changes and see the widget in action on your website.

RSS / MORE WAYS TO DISPLAY:::

There is so much more you can do with your custom post types. You can learn to add your custom post types in main
www.wpbeginner.com/wp-tutorials/how-to-add-custom-post-types-to-your-main-wordpress-rss-feed/
RSS feed or create a
www.wpbeginner.com/wp-tutorials/how-to-make-a-separate-rss-feed-for-each-custom-post-type-in-wordpress/
separate feed for each custom post type.

For more hacks, see our list of the most useful WordPress custom post types tutorials.

If you’re looking for a no-code solution to customize your custom post type archive pages, then we recommend taking a look at a WordPress page builder plugin
www.wpbeginner.com/beginners-guide/best-drag-and-drop-page-builders-for-wordpress/
like Beaver Builder or Divi because they both can help you do that.

We hope this article helped you learn how to create custom post types in WordPress. You may also want to see our guide on how to increase your website traffic with practical tips.

If you want to enable heirarchical relationships on a pods custom post type, in addition to clicking “Heirarchical” in the “Advanced Options” tab, you also need to click “Page Attributes” under “Supports” (which is also in the advanced options tab).

Yes, you can get that exact system for your custom post type. Under the advanced options tab, select the hierarchical option and in the supports section, select page attributes.

For example, say your site has a Resource Library where you display videos, webinars, documents, white papers, etc. This is a perfect case to add a custom post type called “Resources” and a custom taxonomy called “Resource Types”, where videos, webinars, documents, and white papers are the taxonomy’s terms. As you’re adding resources you can group them according to their type and display those groups to your users. To view all videos you can go to yoursite.com/resource-type/videos, and WordPress will automatically display all the resources with the “videos” term. When using a hierarchical taxonomy, you can nest terms inside of each other.

So, if you had different types of videos, you could do:

Videos – yoursite.com/resource-type/videos
Patient Videos – yoursite.com/resource-type/videos/patient-videos
Doctor Videos – yoursite.com/resource-type/videos/doctor-videos
Additionally, with a little configuration, you can update the URLs of your post type to utilize your taxonomy terms. Continuing with our Resource Library example, the URL to a video could look like this: yoursite.com/videos/patient-videos/your-video-name-here.

custom post type called “Resources” – Sortables
custom taxonomy called “Resource Types” –
videos, webinars, documents, and white papers are the taxonomy’s terms

post type: Sortables
custom taxonomy: Sort Levels
terms: level 1 / level 2 / level 3 / level 4 / level 5 / Sort Notes

post type: Agendas
custom taxonomy: Agenda Item
terms: Site Updates / Marketing & Promotions / Assets / Development / New Business / Creative / Housekeeping / Action Items /
Agenda Notes + Agenda Owner + Agenda Due

ORDER THINGS:
www.nsp-code.com/advanced-post-types-order-description-and-usage/understanding-sort-list-settings-area/

[php] [apto_reorder sort_id="82" hide_archive="true"] [/php] Also affected by user role –

capability=”edit_pages” allows editors and up to edit page

Summary of Roles #Summary of Roles
Super Admin – somebody with access to the site network administration features and all other features. See the Create a Network article.
Administrator (slug: ‘administrator’) – somebody who has access to all the administration features within a single site.
Editor (slug: ‘editor’) – somebody who can publish and manage posts including the posts of other users.
Author (slug: ‘author’) – somebody who can publish and manage their own posts.
Contributor (slug: ‘contributor’) – somebody who can write and manage their own posts but cannot publish them.
Subscriber (slug: ‘subscriber’) – somebody who can only manage their profile.

wordpress.org/support/article/roles-and-capabilities/

This will show default functions to sort them by.

This is overview

www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/

Sort list settings –

Title Contains the Sort title, which is show on top menu within the Re-Order Interface. Use this to make Sort easier to identify in case of multiple tabs.

Description A short description of what current sort does and where it apply. This text also displays for other users users, on top of the page as this settings area is available only for admins.

Menu Location This is the interface where the sort will show up. Using this setting a sort can be relocated to a different interface.

Auto Sort Control if the order is applied automatically to front side. If set for No the order can be retrieved progamatically using ‘orderby’ => ‘menu_order’. For more details see Sample Usage

Admin Sort Control if the order is applied on admin interface.

Allow sorting within default post type interface A Drag & Drop functionality is available to be used within default WordPress post type archive interface, ore details at Customizing sort through default post type archive interface

Send new items to bottom of list If set for “Yes”, any new posts on this order list will append to bottom instead top as default. On front side the sort will apply accordingly with the new posts at the end of the list.

Thumbnails Show the featured thumbnail for posts within the sort list. This can be also controlled temporary using the Toggle Thumbnails button located within the sort list header.

Posts Per Page Allow to split the list into paged sections, when long objects list.

Posts Per Page – The number of posts to show on page The number of objects to show on a list chunk.

Posts Per Page – Offset Posts The number of objects to show above and underneath the main sort list chunk. The objects are adjacent to the main list, to allow easy transition for a post from a page to another.

WPML Synchronize (Only when WPML active) Synchronize the custom order across all other languages. This will help to maintain the same sorting across all sites in case a similar order need to be maintained.

Capability / Role Allow to control the users who can see the interface and customize the sort of this list.

Status List only certain post statuses like Published, Pending, Draft etc.

Understanding Sort List Settings area – Nsp Code
Understanding Sort List Settings area – Nsp Code
Each Sort use it’s own settings, meaning they will not affect other order lists. Only Admin and SuperAdmin (in case use MultiSite environment) can see the Sort List Settings area. The Sort List Settings area consist of three sections: Query Rules Con

Type 1 –

www.nsp-code.com/advanced-post-types-order-description-and-usage/create-simple-sort-for-a-custom-post-type/

USE CONDUCTOR::