Assuming post type is my-post-type
.
We can create a page template with custom query using WP_Query
.
Let’s say we create template-multier.php
with the below code in the root directory of the active theme.
<?php
/*
Template Name: Custom Post Type Archive
*/
//Custom header stuff here
//Custom query for `my-post-type`
$args = array(
'post_type' => 'my-post-type',
'posts_per_page' => '-1' // All posts
);
$the_query = new WP_Query( $args );
// Sample Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
//Custom footer stuff here
Then we can use above page template to display posts with my-post-type
Related Posts:
- Custom Post Type Settings page, choose page to display archive
- previous_post_link() and next_post_link() with a custom post type?
- Setting a custom sub-path for blog without using pages?
- Loading custom page template via plugin
- Page is defaulting to archive page and not designated template
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- WordPress custom post type archive with description
- Trying to edit the single page from a Custom Post
- Set up Custom-Post-Type Author Archive
- Custom post type is showing custom home page, not archive page
- Create template for taxonomy results limited by Custom Post Type
- Custom post type archive page blank
- My archive-posttype.php template is not loading
- Custom Post Archive is not working
- How can I use archive-{post_type}.php theme template?
- Creating separate feeds for custom post types
- How to integrate single and archive templates for custom post type in any WordPress theme
- Custom Post Type Archive template not being called
- Template code to split a post and print a custom field?
- Specifying a template for custom post type pages
- Is possible register two archive pages for single custom post type?
- Archive page of CPT’s custom Taxonomy
- Invalid content when I try to import custom post type from the old template wordpress
- Post template with breadcrumb needs to show page navigated from
- Finding the CPT archive template source
- Post template not applying on theme (potentially rendering as Page template)
- ACF Pro Accessing fields on a Custom Post Type
- Assign for all post of a post type a specific single-post template
- get_permalink() of page the enclosing page not posts
- get first limited words from a custom post in the archive page
- Show index and not the archive for “Dog Custom Post” with default slug
- Custom post type archive page not showing on archive-posttype.php
- How do I make my archive page look like popular reviewing sites (e.g., Polygon and Gamespot) [closed]
- Display custom post type archive on page.php template
- Making a archive gallery page for a custom post type which already has an archive page
- Why isn’t my custom post type using the corresponding custom post template?
- How to display custom post types AND regular posts separately on a shared taxonomy archive?
- Search page for custom post type
- how to pass args for archive.php query?
- How to make a template for a specific post of a custom post type?
- Apply text based styling done for a single post in WPBakery to all posts / create a template out of it [closed]
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- Pagination not working only on Archive-Name.php using new WP_Query
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
- How to remove custom post type archive
- How to use a custom post type archive as front page?
- How to get the custom post type from an archive page?
- Set posts of a custom post type to be private by default?
- How make get_next_post() return first post when viewing last one
- Get monthly archives for custom post type
- Post type archive page not working
- How to show related posts by category or custom post type?
- ascending order custom post type
- Display taxonomy term only if there’s a value
- Create separate template for shared custom taxonomy with shared terms
- How to delete all posts from a custom post type?
- Update content of multiple pages/posts at once?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- How to Submit Post Via cURL & PHP
- is there a way to retrieve posts that do not have a featured image assigned?
- Custom Post Type template stored in plugin folder not showing in post attributes dropdown
- Custom template won’t load for a custom post type (custom permalinks used)
- CPT custom archive template does not get loaded
- Custom Post Type Archive URL is wrong
- How to use custom template files in deeper directory?
- Canonical url differs from custom post type archive URLs
- Custom post type archive pagination 404
- posttype/taxonomy/term archive page 404 error
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- How to sort posts in a custom post type by title in ascending order by default?
- Conditional for a Single Post That Belongs to a Category?
- Multiple pages per post (not pagination)
- What’s an efficient way to change the post status of many posts at once?
- Custom Post type date archive for custom taxonomy
- Custom Post Type homepage template
- Copy/Move selected taxonomy terms to another taxonomy for posts
- WordPress post carousel
- Display Posts Query with IF function
- How to setup different permlalinks for posts and pages?
- wp_post_delete is deleting all offices
- Why doesn’t wp_delete_post allow trashing for custom types?
- Warning , Use of undefined constant PLUGIN_PATH?
- Custom Post Type archive page listing a 404 or single post
- Building Link List for Custom Tax
- post type => ‘any’ not applied my custom queries
- Custom taxonomy template for custom fields loop [closed]
- WP_posts (Not meta) extra custom field column show and change it in a custom post type
- how to make custom post with “publish” default functionality not save in draft?
- Post that populates itself (almost) automatically using data from imported excel file
- How should i name the .php file to show custom posts under a taxonomy’s term?
- How to display data with pagaination on backend?
- Edit post meta direct from post.php?
- How to Arrange Support => Thumbnail
- Front-end form submission not creating post
- Load different template for CPT (in loop) in my plugin?
- custom post type not getting archived?
- Most appropriate way to display CPT’s by children terms of custom taxonomies while retaining desired permalink structure?
- CPT Template Option to Top
- show the most recent date of all posts to display on front end
- Why isn’t page attributes dropdown not showing up in a custom post type