Answers.Body: <p>I finally figured out the issue!</p>
  
  <p>When CiviCRM was applying the template in <code>civicrm.basepage.php</code>, <code>$page_template</code> was coming back as <code>page.php</code>, but my base template was actually named <code>base.php</code>.</p>
  
  <p>I added the following code in my theme's initialization and it resolved the issue:</p>
  
  <pre><code>add_filter( 'civicrm_basepage_template', 'psca_civicrm_basepage_template' );
  function psca_civicrm_basepage_template( $template ) {
    return 'base.php';
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-26T03:27:05.563Z
Answers.Text: Great solution. For some reason the correct method of loading a Wordpress template in CiviCRM wasn't working for me, and this fixed it, by adding in functions.php. I'd be interested in knowing what prevented CiviCRM from loading the template that was assigned to it. The page loaded with the correct template when loaded without parameters (eg http://example.com/civicrm/ but not when loaded as http://example.com/civicrm/?page=CiviCRM&q=civicrm/contribute/transact&reset=1&id=1
Answers.UserDisplayName: fred2
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-26T14:57:19.920Z
Answers.Text: Glad it worked for you! If you check out https://github.com/civicrm/civicrm-wordpress/blob/master/civicrm.php#L322, you will see that the function `civicrm_in_wordpress_set()` checks to see if the parameter `page` is set to `CiviCRM` in the URL (`?page=CiviCRM`). If so, it attempts to load the CiviCRM headers, templates, etc based on some other conditions. Since example.com/civicrm does not have this parameter, none of the assets are loaded and it's just loaded as a regular WordPress page.
Answers.UserDisplayName: Nick Tiberi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-13T01:32:09.413Z
Answers.LastActivityDate: 2015-09-13T01:32:09.413Z
Answers.UserDisplayName: Nick Tiberi
Answers.Body: <p>Sorry, I don't have enough reputation to comment.</p>
  
  <p>As Jon says, you need to go to <strong>CMS Database Integration</strong></p>
  
  <p>www.example.com/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm/admin/setting/uf&amp;reset=1</p>
  
  <p>There you have the WordPress users table and the WordPress base page, I would suggest to create an empty page named CiviCRM - slug 'civicrm' and use that page as your base page in the menu mentioned above. </p>
  
  <p>This should be the default behaviour when you install Civi, as Civi automatically creates this page and sets it as the default base page, more info about this <a href="https://civicrm.org/blogs/haystack/working-civicrm-46-wordpress" rel="nofollow">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-06T04:32:36.590Z
Answers.Text: Thank you for the information! I did see that page, but was not sure it was the same one Jon was talking about since I assumed there would be more options available. My WordPress base page is definitely "civicrm" and the page exists here: http://pghchoralarts.org/civicrm/ However, I am not so sure that things are integrated properly due to the problem I am experiencing in my comment to Jon's post (after submitting a CiviCRM contribution form, I am sent to an unstyled page with no template included).
Answers.UserDisplayName: Nick Tiberi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-07T08:21:04.337Z
Answers.Text: Could you try to switch to the default Wordpress theme and report back?
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-07T08:28:15.687Z
Answers.Text: You can easily create a clon of the site with the [Duplicator](https://wordpress.org/plugins/duplicator/) plugin, and change the theme on the cloned site.
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-07T23:00:03.020Z
Answers.Text: Aha! It works with the twentyfifteen theme — the link in my question is wrapped by the theme instead of being an unstyled HTML page. My theme is a child theme of an old version of [roots theme](https://roots.io/), which structures files a little differently than some more conventional WP themes. Is there something in particular I should change in my page templates to get this to work? Not quite sure how CiviCRM hooks into Wordpress pages. Thanks again for your help!
Answers.UserDisplayName: Nick Tiberi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-07T23:56:50.733Z
Answers.Text: I think the way Civi hooks into the page is with the wp_head() function, you can view the source here: https://github.com/civicrm/civicrm-wordpress/blob/master/civicrm.php line 1010 (I'm on mobile with Octodroid, it might be different on desktop), I would suggest to enable Civi's debug and backtrace and also WordPress's debug, submit the form and check the Civi log at /wp-content/plugins/files/civicrm/ConfigAndLog. My php knowledge is very limited, but perhaps someone else here can help you.
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-05T21:57:32.713Z
Answers.LastActivityDate: 2015-09-05T21:57:32.713Z
Answers.UserDisplayName: Andrei
Answers.Body: <p>It's easiest if you think of it as "Adding my contribution page to a WordPress page".</p>
  
  <p>When editing a WordPress page, there is a CiviCRM button that allows you to insert a shortcode to insert a contribution page. </p>
  
  <p>Also - it sounds like your base page isn't set. Contribution pages should inherit the default theme. <strong>Check Administer menu > System Settings > CMS Integration Options</strong>. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-05T00:52:52.933Z
Answers.Text: Thanks for your input! I actually did set one of those pages up here: http://pghchoralarts.org/test-contribute-page/
  
  Aside from some CSS wonkiness, the page integrates into my theme fine. However, when I click "confirm contribution" it takes me to that unstyled page. I looked in Administer > System Settings, but don't see "CMS Integration Options" available. Do I have to enable it somehow? I'm running WP 4.3 and CiviCRM 4.6.8. Here is what I see: http://imgur.com/WuZpwIh
Answers.UserDisplayName: Nick Tiberi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-04T23:05:01.530Z
Answers.LastActivityDate: 2015-09-04T23:05:01.530Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I have a contribution page located here: <a href="http://pghchoralarts.org/civicrm/?page=CiviCRM&amp;q=civicrm/contribute/transact&amp;reset=1&amp;id=1" rel="nofollow">http://pghchoralarts.org/civicrm/?page=CiviCRM&amp;q=civicrm/contribute/transact&amp;reset=1&amp;id=1</a></p>
  
  <p>I haven't gone through the entire process of testing the PayPal integration yet, but one thing I am having a bit of trouble with is figuring out how to incorporate the rest of my Wordpress theme into this page.  Right now the page is an incomplete, unstyled HTML document, and I want to be able to essentially wrap my WordPress theme around it. Is there a fairly straightforward way to do this?</p>
  
  <p><strong>EDIT:</strong> I have narrowed down my issue to the fact that <code>wp_head()</code> in <code>civicrm.php</code> does not get called when it should. I have verified that <code>CiviCRM_For_WordPress-&gt;wp_head</code> gets added as a hook in the main <code>wp_head()</code>, but my theme does not call it when the main WordPress <code>wp_head()</code> is called. When I switch to twentyfifteen theme, the <code>wp_head()</code> function in <code>civicrm.php</code> gets called as expected. Any ideas on what may be going wrong?</p>
  
Tags: <civicontribute><wordpress><contribution-page>
Title: How can I add my Wordpress Site's template to my contribution page?
ThreadText: # How can I add my Wordpress Site's template to my contribution page?
  
  (Asked by: username_0 on 2015-09-04)
  
  I have a contribution page located here: <http://pghchoralarts.org/civicrm/?page=CiviCRM&q=civicrm/contribute/transact&reset=1&id=1>
  
  I haven't gone through the entire process of testing the PayPal integration yet, but one thing I am having a bit of trouble with is figuring out how to incorporate the rest of my Wordpress theme into this page. Right now the page is an incomplete, unstyled HTML document, and I want to be able to essentially wrap my WordPress theme around it. Is there a fairly straightforward way to do this?
  
  **EDIT:** I have narrowed down my issue to the fact that `wp_head()` in `civicrm.php` does not get called when it should. I have verified that `CiviCRM_For_WordPress->wp_head` gets added as a hook in the main `wp_head()`, but my theme does not call it when the main WordPress `wp_head()` is called. When I switch to twentyfifteen theme, the `wp_head()` function in `civicrm.php` gets called as expected. Any ideas on what may be going wrong?
  
  **Tags:** civicontribute, wordpress, contribution-page
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2015-09-13. Score: 2 | Accepted answer
  
  I finally figured out the issue!
  When CiviCRM was applying the template in civicrm.basepage.php, $page_template was coming back as page.php, but my base template was actually named base.php.
  I added the following code in my theme's initialization and it resolved the issue:
  add_filter( 'civicrm_basepage_template', 'psca_civicrm_basepage_template' );
  function psca_civicrm_basepage_template( $template ) {
    return 'base.php';
  }
  
  > **Comments:**
  > **username_1**: Great solution. For some reason the correct method of loading a Wordpress template in CiviCRM wasn't working for me, and this fixed it, by adding in functions.php. I'd be interested in knowing what prevented CiviCRM from loading the template that was assigned to it. The page loaded with the correct template when loaded without parameters (eg http://example.com/civicrm/ but not when loaded as http://example.com/civicrm/?page=CiviCRM&q=civicrm/contribute/transact&reset=1&id=1  
  > **username_0**: Glad it worked for you! If you check out https://github.com/civicrm/civicrm-wordpress/blob/master/civicrm.php#L322, you will see that the function `civicrm_in_wordpress_set()` checks to see if the parameter `page` is set to `CiviCRM` in the URL (`?page=CiviCRM`). If so, it attempts to load the CiviCRM headers, templates, etc based on some other conditions. Since example.com/civicrm does not have this parameter, none of the assets are loaded and it's just loaded as a regular WordPress page.  
  
  ---
  
  ### Answer by username_2 on 2015-09-05. Score: 3
  
  Sorry, I don't have enough reputation to comment.
  
  As Jon says, you need to go to **CMS Database Integration**
  
  www.example.com/wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/setting/uf&reset=1
  
  There you have the WordPress users table and the WordPress base page, I would suggest to create an empty page named CiviCRM - slug 'civicrm' and use that page as your base page in the menu mentioned above.
  
  This should be the default behaviour when you install Civi, as Civi automatically creates this page and sets it as the default base page, more info about this [here](https://civicrm.org/blogs/haystack/working-civicrm-46-wordpress).
  
  > **Comments:**
  > **username_0**: Thank you for the information! I did see that page, but was not sure it was the same one Jon was talking about since I assumed there would be more options available. My WordPress base page is definitely "civicrm" and the page exists here: http://pghchoralarts.org/civicrm/ However, I am not so sure that things are integrated properly due to the problem I am experiencing in my comment to Jon's post (after submitting a CiviCRM contribution form, I am sent to an unstyled page with no template included).  
  > **username_2**: Could you try to switch to the default Wordpress theme and report back?  
  > **username_2**: You can easily create a clon of the site with the [Duplicator](https://wordpress.org/plugins/duplicator/) plugin, and change the theme on the cloned site.  
  > **username_0**: Aha! It works with the twentyfifteen theme — the link in my question is wrapped by the theme instead of being an unstyled HTML page. My theme is a child theme of an old version of [roots theme](https://roots.io/), which structures files a little differently than some more conventional WP themes. Is there something in particular I should change in my page templates to get this to work? Not quite sure how CiviCRM hooks into Wordpress pages. Thanks again for your help!  
  > **username_2**: I think the way Civi hooks into the page is with the wp_head() function, you can view the source here: https://github.com/civicrm/civicrm-wordpress/blob/master/civicrm.php line 1010 (I'm on mobile with Octodroid, it might be different on desktop), I would suggest to enable Civi's debug and backtrace and also WordPress's debug, submit the form and check the Civi log at /wp-content/plugins/files/civicrm/ConfigAndLog. My php knowledge is very limited, but perhaps someone else here can help you.  
  
  ---
  
  ### Answer by username_3 on 2015-09-04. Score: 2
  
  It's easiest if you think of it as "Adding my contribution page to a WordPress page".
  
  When editing a WordPress page, there is a CiviCRM button that allows you to insert a shortcode to insert a contribution page.
  
  Also - it sounds like your base page isn't set. Contribution pages should inherit the default theme. **Check Administer menu > System Settings > CMS Integration Options**.
  
  > **Comments:**
  > **username_0**: Thanks for your input! I actually did set one of those pages up here: http://pghchoralarts.org/test-contribute-page/  Aside from some CSS wonkiness, the page integrates into my theme fine. However, when I click "confirm contribution" it takes me to that unstyled page. I looked in Administer > System Settings, but don't see "CMS Integration Options" available. Do I have to enable it somehow? I'm running WP 4.3 and CiviCRM 4.6.8. Here is what I see: http://imgur.com/WuZpwIh  
  
  ---
  
  