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
- List children on child post
- Restrict custom post type from appearing with ?post_types=
- Show custom post type filtered by category
- Displaying Page as Custom Post type landing Page
- URL of a custom post type’s post format archive?
- create parent post using wp_insert_post
- Custom Post Type archive loop separated by term, in specific term order
- Turn on and off custom post type from admin?
- Missing Posts in Custom Taxonomy List
- Show only posts from one category on custom post type archive page
- Display random posts, but omit the post it is on?
- Query with no terms uses index.php template instead of archive.php
- How do I do this with WordPress? Taxonomies?
- Disable block with taxonomies at post page
- I would like to have different styles for my posts based on the content of each post
- How can i add thumbnails images to particular post (using code not admin pannel) in wordpress
- How should I structure my post types?
- Showing posts from different categories and from custom post type
- Get latest 3 posts from multiple CPT in one query
- Template for custom post with custom taxonomy
- WordPress Custom Post Type Children Template
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Which post does a taxonomy term belongs to?
- Extending AZIndex plugin to use custom post types and custom taxonomies
- Getting template_include to work when allow_url_include is off?
- List custom taxonomy specific to one custom post type
- How to use has_archive but disable feed per post type?
- Post image in WordPress not appearing on home page
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- Custom post type content using custom fields without template
- Meta query for custom post type ignored in main query
- Changing custom type name hides the posts
- Isotope Filtering with Bootstrap Tabs – Custom Post Type Query Loop in each Tab (Have to click twice to filter)
- Display Ad on Specific Categories
- Custom post type: Disable single page, but keep archive
- WordPress post_where & posts_join not working only for custom post type
- Hiding posts by other users and non-logged in
- 2 Templates 1 custom post type according url
- Update Post Meta for a logged in user
- Add custom field to Posts and sort by it
- Add custom post type settings to wordress default posts
- Use Custom Post Type archive page for the taxonomies term archive page
- Display custom post type category, while in a CPT category, then the posts beneath
- Get related posts of child term of custom post type
- Two Custom Post Types Many to Many Relationship
- Problem with displaying posts in the CPT category
- Custom taxonomy and custom post type – wrong permalinks and template
- JS innerhtml changing style when using AJAX
- Show titles, date of all posts on single category page
- Can I override a CPT template on a per post basis with Gutenberg block editor?
- Why is my site using index.php instead of archive?
- Side effects of Script and Iframe in post
- How to change the post type a theme shows by default?
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- Set a checkmark in a category based on a URL-parameter
- CPT archive admin menu label