I'm on version 4.6.11 of the CiviCRM plugin for WordPress, WP version 4.4.1.

I expect this has something to do with shortcodes, hijacking, and maybe some other things related that I'm having trouble understanding. Here's what's happening:

I have created a WP page template called page-civiform.php. It is intended to be used by site admins to create event registration pages and donate pages, and it has some custom fields and specific styling/branding. Admins use the main content WYSIWYG editor to paste a shortcode from CiviCRM that creates their event registration form or donate form. All is well, and these pages look good.

Then, once a user registers or donates, the URL of the very page is appended with a query string, and it appears to be retrieving the default page.php sidebar (which is called in page.php). BUT, the body classes are not those of page.php. Instead, the body classes are exactly the same as those of the previous page where the shortcode was pasted - that page which is using page-civiform.php template. That's a problem, because it ends up creating an unprofessional appearance with a wonky layout.

I created a page with slug 'civicrm' and in WordPress Base Page setting, it is set to use that page, which does indeed use page.php as its template. On top of that, per the answer here, I put a filter into functions.php file to specify using page.php. None of this appears to have any effect. Removing that filter and changing the WordPress Base Page (to anything else) also appears to have no effect.

Seems the wires are crossed here. I did see this issue, discussion of which sounds unpromising.

I need the Civi-generated pages to be style-able differently from the pages where shortcodes are pasted; I can't do that when the selectors are identical.

Could this issue be related? Is there a setting somewhere that I am unaware of?

  • I'm a bit confused. I followed your steps and, for me, all stages of event registration remain on the static page which has the shortcode in it. At all points, the custom 'page-civiform.php' template is applied. Do you (or do you not) want this to be the case? Jan 18, 2016 at 12:47
  • Hi Christian, thanks for stopping in. In my site, the template 'page-civiform.php' has a custom field (ACF) and no sidebar. While the subsequent 'pages' of the registration/donation process do indeed get the body classes for the page-civiform.php file, they don't get that custom field (it's just an image), which is okay, but they problem is that for some reason they're getting a sidebar which is only supposed to be called on the default template. Jan 24, 2016 at 2:21
  • Hi Susan, could you use a Feature Image instead of ACF? Does 'page-civiform.php' have a call to get_sidebar()? If so, how are you conditionally hiding it? Jan 27, 2016 at 15:02
  • A Featured Image might work; I'll try that. The template 'page-civiform.php' doesn't have a get_sidebar() call. Here is a link to a gist of it: page-civiform.php. Jan 28, 2016 at 5:38
  • So I'm not clear what the markup is that appears. Is it the theme's sidebar markup or simply your empty '.left-third'? Jan 29, 2016 at 9:55

1 Answer 1


Im answering my own question and I'll probably go overboard in explaining everything exhaustively, but I sunk too much time into this to just let my understanding disappear into my own forget.

In this particular site, site admins use the custom page template 'page-civiform.php' whenever they want to create a page which will contain a CiviCRM form, inserted via shortcode, and this page template allows them to also insert additional content via a custom field which will display in a column alongside the form. Looks nice.

End users submit the form, and then CiviCRM automatically generates each subsequent page (thank you page, event registration confirmation page, etc).

These pages will have the same body classes as the page where the shortcode was inserted.

BUT these Civi-generated pages do NOT use the same content as the page with the shortcode. And by content, I think this means everything in between get_header() and get_footer(). Instead, they use the content from another page, and there are three ways to specify which page they will use:

  1. If there is no other method utilized to specify which page to use, CiviCRM will use the home page. Again, content, not body classes (that was the source of my confusion).

  2. In CiviCRM > Administer > System Settings > CMS Database Integration, the WordPress Base Page can be set to a specific URL. Then that page's content will be used.

  3. It is also possible to specify the page via a filter which would go into functions.php or a plugin. And here's code for that:

add_filter( 'civicrm_basepage_template', 'my_basepage_template' );

function my_basepage_template( $template ) {

return 'page.php'; //whichever template you want


The path of least resistance here is to have ALL of these pages (pages with shortcode inserted as well as any resultant civi-generated pages) have the same template, because then this whole situation wouldn't matter. But on this site, we want some content in a column next to the shortcode-generated form, so that's why we have a separate page template with a custom field ('page-civiform.php').

Here is 'page-civiform.php' so you can see how the custom field is conditionally included or not. The presence of that conditional statement would actually allow me to set this page as the WordPress Base Page, and it would yield the same result, which in this casse is two columns on page with shortcode, one column (just Civi's content) on auto-generated pages.

Basically, this all comes down to having different design/layout for pages with shortcodes vs civi-generated pages.

  • Thanks for taking the time to explain this - this very issue has been driving me up the wall. Another way this problem presents itself is on a CiviCRM form that throws a user error - such as not entering a required field. In that case the appended parameters seem to "hijack" not only the page's body content, but also any templated sidebars, etc. Feb 24, 2016 at 18:12
  • @susan-langenes have you assigned this template to the civicrm base page? I looked at doing this via code at install (defining a page template for the /civicrm basepage) but in the end it was decided that might be too treacherous with all the themes out there. Christian Wach did the work refactoring base page and he may have some more thoughts Feb 26, 2016 at 21:03
  • I think I've ironed out the confusion in github.com/christianwach/civicrm-wordpress/tree/CRM-18113 Feb 27, 2016 at 15:01
  • The new behaviour is that Civi leaves the template alone unless it is the site homepage being used as the basepage. This is really the only situation where Civi has to take control, because of the likelihood that the homepage is the list of posts or an incompatible template. See my comments in the code. Feb 27, 2016 at 15:02
  • @ChristianWach that looks great - very clear and much more understandable! Mar 8, 2016 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.