You can not replace half of a template by using filters and hooks if the template itself doesn’t support so.
The template_include
will override an entire template, it means header, body, content, sidebar, footer, and everything.
Now you have these options:
Style Your Template
Create a full single-my_member.php
file and then style it by CSS and probably JS. You need to think of it as a complete template, not just a page to render a few lines of content.
Use preg_replace()
Not a good idea at all, but you could do a preg_replace()
combined with an output buffering and add content to a page’s common places, such as <body>
or <header>
. This might slow down your site a lot, and is not always accurate.
Provide Shortcodes
If you are trying to add limited content ( not a full HTML structure ) to templates, then you might be able to provide some shortcodes for the users to use. The risk of messing with templates here is very low.
Related Posts:
- Can I assign a template to a custom post type?
- Get custom post_type’s archive URL
- single-{$post_type}-{slug}.php for custom post types
- Use template_include with custom post types
- Searching multiple custom post types and pages
- display different template based on post type
- why doesn’t the_content() work in this {single-custom_post_type.php} page?
- Taxonomy, Terms, and Template Files
- previous_post_link() and next_post_link() with a custom post type?
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- tag.php doesn’t work with tags on a custom post type post?
- Setting a custom sub-path for blog without using pages?
- Custom Post Types 404 Issue
- How to add custom content template part for a custom post type on main query using a plugin
- Assign single template to multiple custom post types?
- Template for specific post of custom post type
- Add Content to Page without shortcodes
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- Loading custom page template via plugin
- Multiple Single Post templates
- How to set a fall back template for a custom post type in a plugin?
- Templates for Custom Post Types and Custom Taxonomies
- Using Templates with Custom Post Type UI
- Get page by template?
- Custom taxonomy query for a custom post type
- Apply template to custom post type
- Page is defaulting to archive page and not designated template
- Get random custom-post-type post to display within content
- How to quickly switch custom post type singular template?
- How to list/show all custom post types regardless of category?
- Custom Post Type Archive URL takes over page URL
- Getting a div content of a post in wordpress?
- Render a different post/template from within the template_include action?
- Sanitizing post content for use in an email
- Need some templating advice for templating with custom post types and taxonomies
- How to query custom posts using a dynamic category
- Using Custom Templates for Custom Post Types for the Genesis Theme Framework?
- Custom Post Type with Nested Taxonomy and Template Files
- Custom Post Type Archive Template
- Custom templates for posts like for pages: page-{id} vs single-{id}
- Posts in Multiple Columns and Rows with one single loop
- Create Pages from Database
- Custom page type – template under page attributes?
- Template tags to display custom post type posts in category template?
- How do I create new content pages for my Custom Post Type?
- Display different gutenberg template from selected post attributes
- Clean URL permalink for custom post type
- custom post type archive template per custom taxonomy term
- where can I see my custom post type archive template?
- Wp-query causing problems with the_content();
- Custom post type loops with different page templates
- Display posts of child category in template
- custom taxonomy – Template not working
- How do I set the content for a post of a particular CPT?
- Include different loop templates in search query
- Use one template for different custom post types with the same markup
- How to avoid hardcoded text in a custom page template?
- Custom page template not being called
- How to display custom post types AND regular posts separately on a shared taxonomy archive?
- Querying multiple taxonomies in URL leads to wrong taxonomy archive
- Load different template for CPT (in loop) in my plugin?
- Search page for custom post type
- How can I pull information from my loop and divide them seperately?
- Custom post type pagination, single page issue
- Multisite – Echo admins profile meta
- Having some trouble properly displaying Custom Post Types in templates
- Custom template support for custom post type?
- Storing postID in session variable to query database when visitor on custom template page
- query_post while (have post) get_template_part()?
- Custom Post Type Template based on Taxonomy
- Template with Custom Post Type (Custom Tables) does not work
- Using custom post types within a section of a template
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Specifying Default Template for Hierarchal Custom Post Type [duplicate]
- Most appropriate way to display CPT’s by children terms of custom taxonomies while retaining desired permalink structure?
- Custom Post Type Template Based on Page Slug?
- how to pass args for archive.php query?
- Add HTML before a specific div?
- Navigation links to posts in current term shortcode
- How to make a template for a specific post of a custom post type?
- Problem retrieving custom field for a custom post type
- Only One Post of Custom Post Type Appearing on Template Page
- CPT Template Option to Top
- WP_Query is getting the post but the_post() not rendering any Post
- Apply text based styling done for a single post in WPBakery to all posts / create a template out of it [closed]
- Show my custom post id if a country or ip
- PHP Button Custom link [closed]
- How to create custom page templates with default page layout framework?
- Choose custom post type template by category
- using a template for more then 1 page
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- Custom post type is_singular condtional not working when managing sidebar display
- Why isn’t page attributes dropdown not showing up in a custom post type
- How can I produce multiple webpages with a different output based on one entry/Page/custom Page?
- How to check if a custom post type uses a custom template?
- Custom post type template not loading from plugin
- How can I allow plugin users to define layouts for a custom post type
- How to change layout of post types templates dynamically for separate posts?
- Custom PHP Template in Twenty Twenty-Four
- Add block templates (html) via plugin for custom post type