How to integrate single and archive templates for custom post type in any Wordpress theme

I am working on my new WP Plugin for advanced control of custom post types and meta boxes.

Actually, I am working on an HTML Builder for the full customization of single and archive templates for the registered CPT.

I am struggling now with this problem: how to integrate these new templates into any Wordpress theme?

I found this:

Dynamically override page.php or single.php with custom templates using function

It fits my needs indeed but since every Wordpress theme is different I don't know how to integrate my custom content into the theme structure with its elements like any other template page (headers, footer, sidebar, etc...). Is there a way to use for example single.php base structure overriding only the inner content?

I was looking at other plugins like Pods or Toolset but I can't figure out how to achieve the same result.

I was thinking also to create a dedicated theme to integrate my custom templates, but it doesn't really make me happy.

Anyone can help me?

Thanks in advance

Topic archive-template custom-post-type-archives page-template custom-post-types Wordpress

Category Web


Is there a way to use for example single.php base structure overriding only the inner content?

The main content of pages and posts is output using the the_content() function. This can be filtered and changed by plugins using the the_content filter. However this only outputs the content entered into body of the editor. It does not include the title, sidebars, metaboxes, widgets, comments or any other content. This is the closest you will get. The output and structure of everything else is entirely up to the theme, and there's no standardisation.

So for anything more than filtering the content there is simply not enough mandated consistency between WordPress themes for something like this to be feasible.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.