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:
- Use template_include with custom post types
- display different template based on post type
- 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
- Setting a custom sub-path for blog without using pages?
- How to add custom content template part for a custom post type on main query using a plugin
- Template for specific post of custom post type
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- How to set a fall back template for a custom post type in a plugin?
- Templates for Custom Post Types and Custom Taxonomies
- Page is defaulting to archive page and not designated template
- How to quickly switch custom post type singular template?
- How to list/show all custom post types regardless of category?
- Sanitizing post content for use in an email
- 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
- Create Pages from Database
- Wp-query causing problems with the_content();
- Custom post type loops with different page templates
- How do I set the content for a post of a particular CPT?
- Include different loop templates in search query
- Single page template for custom post_type
- Turn query string to sub page
- WordPress Template Hierarchy
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- Multiple templates for a custom post type
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- How to show the archive / post type description on Single templates
- Set up Custom-Post-Type Author Archive
- Query with no terms uses index.php template instead of archive.php
- WordPress Custom Post Type Children Template
- Getting template_include to work when allow_url_include is off?
- WordPress Doesn’t Generate Taxonomy Archive
- the_content filter on some post types only not working
- Filter widget outputs
- Adding Page Templates to post but it ignored it
- Template for all categories of a custom post type?
- WordPress custom taxonomy template not working
- How to specify a template for a path like http://example.com/something?
- WordPress 3.9 not using custom template
- Template files for Custom Post Type and Taxonomy
- How to Create Template File for Parent Page of Custom Post Type
- Custom post_type search pages
- how to remove pages loading with the archive templates
- Custom Empty Results page for my Custom Post Type
- Loop through custom posts by taxonomy and display the titles in a list, it is repeating 8 times
- Creating Sections for Post Types
- Custom post types with categories in template
- How can I remove filters from custom post types?
- How can I trace inconsistency in loading a template?
- Assigning alternate single-{cpt} template based on blog_id in multisite
- assign different templates to custom post type with homepage loop
- Separate Content from gallery (custom post type)
- Get template part with CPT and Custom Taxonomy conditionals
- Displaying a list of Contacts
- How to change single custom post template by custom taxonomy?
- Custom permalink structure for remote content pages
- Setting a homepage – doesn’t seem to work
- Custom post type draft use wrong template
- How can I add in post’s the text “No content”
- filter the_content, custom post type, and wp_query
- How to customize `Edit-Post` Screen
- Calling a div and content in php?
- Tag template not returning posts [closed]
- Function to allow single post template based on custom taxonomy?
- Specifying a template for custom post type pages
- Custom Post Type, Custom Taxonomy Template: How to get current taxonomy name?
- Custom post type set default template using block editor
- A certain theme is forcing it’s singular post layout
- Post template not applying on theme (potentially rendering as Page template)
- Custom post type defaults to index.php for archive page
- Custom Post Taxonomy Template Not Loading Properly
- Is it possible to link an external stylesheet, exclusively within a specific single post template?
- Templating advice sub posts of a CTP
- Question on templates
- Assign for all post of a post type a specific single-post template
- Custom post type option page template
- Taxonomy template file not working with a taxonomy that contains a slash
- How can I load Template file from wordpress plugin
- How to override post-new.php with custom template
- How can I find out what template is my custom post type using?
- Can I organise my custom post types by page?
- I want to create an archive and single page for a custom taxonomy for a custom post type
- Redirect to different template other than single-custompost.php
- WordPress Custom taxonomy template
- custom post type plugin – single template
- Use one template for different custom post types with the same markup
- How to display custom post types AND regular posts separately on a shared taxonomy archive?
- How can I pull information from my loop and divide them seperately?
- Custom template support for custom post type?
- Storing postID in session variable to query database when visitor on custom template page
- Custom Post Type Template Based on Page Slug?
- Add HTML before a specific div?
- How to make a template for a specific post of a custom post type?
- 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]
- 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
- How can I produce multiple webpages with a different output based on one entry/Page/custom Page?