Incorrect base wrapper being used, I'm at a loss

Sorry for what must be a tiring question. I swear I’ve spent 3+ hours on this already today and I’m asking because I’m out of ideas. I know I’ve gotten it to work in the past where I have used a base-[template-name].php file instead of the default base.php or whatever. But even though I think I have the right files created, it’s still using the default base.php in a specific instance, detailed below.

Basically I have a plugin for ‘calls to action’ that as far as I can tell is just a custom post type of ‘wp-call-to-action’. The plugin outputs an iframe on your page that is supposed to basically contain the output of the_content() for whatever call to action you select. But what’s happening instead is the whole roots wrapper from base.php, etc. is also being output inside the iframe.

I figured that I could just make a base-[whatever].php file in my theme folder that had no content other than include roots_template_path(); (i.e it would output no head or body or anything) and, as long as I name it correctly, that stripped-down base wrapper will be used and nothing other than the_content() will be output to the iframe. But it is clearly using the base.php wrapper no matter what I name the other ones I’m putting in there. What am I doing wrong?

Here are some filenames I’ve tried, which did not seem to be used (I know some of these are not really expected to work, but I got desperate and started trying whatever I could think of):

  • /base-4470.php (ID of call to action custom post?)
  • /base-page-4470.php (same idea)
  • /base-page-download-executive-threat-brief.php (slug of call to action custom post?)
  • /base-single-wp-call-to-action.php (slug of custom post type?)

I added some code (echo get_page_template()) to ‘templates/page-header.php’ which supposedly outputs the currently used template’s filename. That said it was using the template ‘/page.php’, so I made a duplicate called ‘/page-4470.php’ and it used that instead. But it’s not wrapping using base-page-4470.php! Shouldn’t it be? I am super confused.

Here is a link to the custom post call to action itself:
http://www.speartip.com/cta/download-executive-threat-brief/
When all is working as desired, the only thing you’ll see here is an image, wrapped in a link. But right now, there’s all sorts of other stuff from base.php.

I am hoping that my brain is just fried and I am forgetting something basic. If not, what is goin on? Thanks in advance!

(FYI - this is for a site designed a while back, so it was built off Roots 5.2. In case that matters or there is some known issue that’s been fixed in recent versions. :smile:)

Try the code I posted here and see if the templates printed match your debug code. The alternative is to remove the wrapper remove_filter('template_include', array('Roots_Wrapping', 'wrap'), 99); depending on post type.

Thanks for the quick response. Adding that code outputs:

THE MAIN TEMPLATE BEING USED IS:
[…]/WP-CONTENT/PLUGINS/CTA/TEMPLATES/BLANK-TEMPLATE/INDEX.PHP

THE BASE TEMPLATE BEING USED IS:
[…]/WP-CONTENT/THEMES/CYBER-COUNTER-ESPIONAGE/BASE.PHP

Unfortunately, that doesn’t tell me much since I already knew it was using base.php :), but maybe it tells you something!

I like the idea of removing the base wrap entirely (since it’s what I want to do in this case anyway) but I am not sure exactly how to implement the code you provided. I tried adding the following to the end of ‘lib/custom.php’ but it doesn’t seem to be doing anything:

if( 'wp-call-to-action' == get_post_type() ) { remove_filter('template_include', array('Roots_Wrapping', 'wrap'), 99); }

If you can tell me exactly what I’m messing up here, I would really appreciate it. Thanks!

This is happening because the plugin is using its own template.

Try wrapping your code in a function and attach that to the template include filter with a priority of 98 or less.

I really appreciate you trying to help me… but I am a designer primarily and this is a bit out of my depth. I understand the gist of what you’re saying but I don’t have any idea the way I would need to write it. I tried:

function remove_cta_wrap() { if('wp-call-to-action' == get_post_type() ) { remove_filter('template_include', array('Roots_Wrapping', 'wrap'), 99); } } add_filter('template_include', 'remove_cta_wrap', 50);

But it gave me a white screen of death on the site. I don’t understand what any of these things really do, so I feel like I’m just guessing when I try to modify it. I just want to remove the roots wrapping for the custom post type ‘wp-call-to-action’. Thanks in advance.

You tried what I was suggesting to try, so you have a pretty good gist of things.

Try changing the priority to 9 or lower (so it runs before anything else) and/or manually include the template the line after you’ve removed the filter.