You don’t reuse a specific page’s data via get_template_part
, you query for a specific page’s data and use get_template_part
to output the result. Look at how any of the core-bundled themes use get_template_part
within the loop to output the main query for an example.
Query for the page:
$query = new WP_Query( array(
'post_type' => 'menu',
'name' => 'monday'
) );
if( $query->have_posts() ){
$query->the_post();
get_template_part( 'menus' );
wp_reset_postdata();
}
Then menus.php
outputs the result:
<?php
the_title();
the_content();
// etc..
Related Posts:
- How to add custom content template part for a custom post type on main query using a plugin
- Get template part based on custom taxonomy term
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Correct way to use get_template_part() and get_post_format() with custom post types?
- get_template_part() – post-meta not working?
- get_template_part for each level of taxonomy term
- get_template_part and template file names
- Get template part using a custom taxonomy term
- Tag page only display 10 posts
- Get Specific Template Part if Custom Field is Some Value
- Custom post type index (maybe using get_template_part)
- Displaying a custom post type using get_template_part into a specific layout
- Get template part with CPT and Custom Taxonomy conditionals
- On click some element i want to use some template
- Shortcode and get_template_part
- query_post while (have post) get_template_part()?
- Combining queries with different arguments per post type
- importing third party json feed as custom post type [closed]
- List the categories under custom taxonomy
- register_post_type & ‘register_meta_box_cb’ argument
- Custom Post Type Archives with 0 Posts Redirects as 404
- How to replicate some of Drupal Views functionality in WordPress?
- Archive page with multiple taxonomies rewrite
- Date archives for custom post type
- WP Rest API Querying Custom Posts by ACF fields
- display multiple term post from taxonomy in a single page
- Dynamic variable for custom taxonomy in loop?
- Allow Author role to publish one post type and not another
- Display posts of child category in template
- What hook should be used to programmatically create a post only when master post is updated?
- How to show post title outside of loop? [closed]
- Prevent author role from editing all posts in custom post type?
- Want to turn WordPress into a paid subscription directory
- Using WPAlchemy metabox values in another metabox
- adding .current* tags to custom post types and taxonomies
- How to get custom post type menu_name?
- Saving repeated option values in a custom query
- Remove custom post type slug not working for child pages
- I am facing problem in my archive page , it is partially working
- Rewrite rules for custom post type slug
- Check if admin is editing page or custom post type
- How to output wordpress custom tags separated by comma?
- Admin notice not displaying
- Custom Image Thumbnails of Different Sizes
- wp_set_object_terms() not adding new term to custom post and custom taxonomy
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- How to allow a custom user role to create, edit, delete a specific custom post type only?
- Prevent stripping MathML tags on post save
- How to set order for a custom post type
- How to get custom post types to play nice with schema.org (aka how to wrap the contents in the schema.org markup)?
- Custom admin post.php page
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- Use Custom Post Type archive page for the taxonomies term archive page
- Nested Custom Post Type or Custom Post Type Parents?
- Hide a widget inside a div on specific type of post
- How to use TinyMCE Editor for one of my custom post meta field?
- Display related custom taxonomy posts in sidebar
- filter search custom field query
- $post not working working in AJAX plugin with custom post type
- Using wp_query to modify the loop in index.php for a CPT
- Getting WordPress Flexslider Item Number
- WordPress Custom Post Type and Shortcode for Portfolio Items
- Custom Post Type setup
- Missing Post from Custom Post Type
- WordPress custom permalink and archive link for custom post type
- Post ordering not working with custom field
- Custom post type tags not showing in search
- Add unique ID number to end of permalink
- How to display tag attribute “target” in the_author_meta( ‘description’ );
- Problem with date comparison for custom fields
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Using global $post; with custom post types
- Sortable column with custom data by date
- Set the main page for custom post type
- Fetch data of 2 relational Custom Post in WordPress
- Limit to one post for each custom post type
- Change dynamically the dropdown list value
- Get related custom post by specifics custom post ID
- Default excerpt for parent of a custom post type
- Add extra elements to the_post in a custom post_type
- Too many revision when post status is changes [duplicate]
- Displaying posts inside table having issues
- load wordpress events into full calendar jquery
- custom post template not getting picked for posts with Unicode title
- Search Custom Post Types in WordPress
- why featured image option isn’t showing in custom post type?
- Displaying custom posts in categories
- Best approach to allow front-end display of posts’ reviewers?
- Query pulling all taxonomies, not one I am specifying
- hide old events custom post type
- Filter Content on all Post Types
- How to query all custom posts of a certain type and checking what category they have
- Post Editor: display categories from current post type taxonomy only?
- show previous/next post orderer by title in custom post types
- Exclude a custom category from a list
- Linking from a list of custom post type items to a single – get_post_permalink not working correctly
- Remove plugin’s custom post type archive page and single pages [closed]
- After wp_insert_post() custom post type does not show in the admin
- I want to understand plugin implementation of custom posts / taxonomies / metaboxes
- Issue displaying multiple TinyMCE editors with WPAlchemy