I'm using the CiviCRM plugin for WordPress, and in the plugin's main file, civicrm.php
, it calls add_action()
to add a function to wp_head()
in order to merge CiviCRM's header with my theme's header:
add_action( 'wp_head', array( $this, 'wp_head' ) );
The actual function within civicrm.php is found below:
public function wp_head() {
echo "calling wp_head"; //added by me to test if the code gets called
// CRM-11823 - If Civi bootstrapped, then merge its HTML header with the CMS's header
global $civicrm_root;
if ( empty( $civicrm_root ) ) {
return;
}
$region = CRM_Core_Region::instance('html-header', FALSE);
if ( $region ) {
echo '<!-- CiviCRM html header -->';
echo $region->render( '' );
}
}
I have confirmed that the code gets called when I switch to the twentyfifteen theme, but on my custom theme (which is based on an old version of Roots), this code does not get called. I have also confirmed that my custom theme is actually calling the main WordPress wp_head()
function.
Any ideas on what could be going wrong in my custom theme that would cause this custom wp_head
hook to not get called or otherwise error out in some way?
wp_head()
is being called in your theme's header?wp_head
to see if that works?wp_head()
function is actually being called in my theme's header. I put an echo in another function and it's being printed. The CiviCRM function, however, is not.