For question as stated it would be easiest to retrieve page’s slug and pass it as second argument:
get_template_part( 'content', get_post_field( 'post_name', get_post() ) );
Note that you would want to have generic content.php
for pages that don’t have dedicated template (if any).
Related Posts:
- Check if a menu is empty?
- Get the php template file from other theme folder
- Exclude pages with certain template from wp_list_pages
- Easiest way to show total number of subpages
- Switching between custom templates in a post type of the admin menu
- is_page_template not working as expected
- How to enqueue CSS and JS only on specific template?
- Custom Template 404 for specific custom post type
- Change title only in dynamic page
- Does wordpress templates always in files or in database?
- Using same variable names in files added with get_template_part()
- Adding wrapper elements in the_date() like in the_title()?
- WordPress template page name displayed on screen
- Prevent header and footer from loading on specific pages with template or plugin
- Contain multiple page templates in one PHP custom template file in WordPress?
- If I define a variable in header.php, how do I make it available to templates?
- Loop on a wordpress Page instead of content coming from the WP text editor
- WordPress post-template null warnings
- How can I edit the content in index.php? [duplicate]
- Automatic Shortcode Creation with Custom Fields [closed]
- Woocommerce Show Single Product on Homepage
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- If tag equals then show else show
- how to show only specific category for a template
- Show a different code on front page to other pages
- get_template_part for specific page
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Inject class in body when particular page template is used
- PHP include is only working in certain places in my custom WP theme
- Use WordPress function in php file
- How to get all author posts outside of author templates
- Add filter multiple times using only one master function
- Create a Blog Template Page
- Showing latest post without 301 redirect
- Show meta box only for default page template
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Display custom field on 404 page outside loop
- single.php with different look by category
- Conditional statement for dates
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Echo a shortcode div after every 3 posts
- How can I display a div ONLY if it is not a certain term page
- Display all pages – in order
- Don’t show certain div on front page?
- If ‘editor’ is empty, then
- Add class to DIV depending on page loaded
- How do I define a lookup table that will work across all PHP elements of the template?
- Editing a PHP file to include a small text piece on every page
- persist a variable set in header.php all the way down to footer.php
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Removing WordPress Footer -without access to PHP code?
- How to set a template with wp_insert_post
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Using ob_start and ob_get_clean with wordpress shortcode
- Why does the Woocommerce grouped template prints the unpublished products?
- Adding conditional text to a PHP Shortcode Template
- Create page template via functions.php?
- Short code template + ajax
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- page-slug.php not working but only for specific slug
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- how to display this functions?
- is_page_template showing partial results
- Adding regular php file to site
- Advice on creating a WP Archive Template with Custom Taxonomy (get_term_meta)
- add_filter function concatenate string and locate_template function
- How to render a block from php template
- Template Loop – add switch case php
- get_page_template_slug returns incorrect path
- Undefined index for default custom theme option
- Override Admin menu icon
- Post repeated when opening in overlay, how do I solve this? [closed]
- Remove conditional tag from header
- Dropdown menu for categories
- How to suppress template-parts in undescores?
- Select through customizer the template part to be viewed
- Need help with pagination
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- Creating custom page template from existing PHP site
- Posts are not looping through correctly
- Display an image based on field value
- Multidimensional Array
- How do I query a single data value from the wp_metadata table?
- Conditional string comparison failing for basename/slug
- Splitting the_content() by size?
- Gravity Forms merge tags in templates?
- Unable to render custom field after attempt to generate a list of recent post in page template
- How to add new CSS file to new PHP file
- Make a page (url) not cacheable [closed]
- “if parent category is” conditional?
- Use of IF statement in Header file
- php loading different structure than source code
- get_template_part function and add images
- pass html code to worpdress
- Conditional for Post Format
- conditional: if is page, and all subpages
- Woocommerce getting top level category parent and make all sub categories have the same template and menu
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Display additional page templates and a sidebar on plugin activation