Details
-
Type: Improvement
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Won't Fix
-
Affects Version/s: 4.2.6
-
Fix Version/s: 4.3.0
-
Component/s: WordPress Integration
-
Labels:
Description
The WordPress integration uses the filter 'the_content' to display public CiviCRM pages in WordPress. This filter is only called when a post is displayed. So when the homepage for a website does not include any posts, going to a CiviCRM event information page or any other public page will display the website's homepage rather than the CiviCRM content.
A workaround is to use the filter 'template_include' instead, which allows us to specify a template that we want to use when displaying CiviCRM content.
This has the added benefit of giving a lot more flexibility to the user since we can now modify this template to include, or not, the WordPress sidebars, widgets, change the styling of content <div> or add custom CSS very easily.
Here is how to implement this change:
modify file wp-content/plugins/civicrm/civicrm.php, line 386:
add_filter('the_content', 'civicrm_wp_invoke');
}
}
changed to:
add_filter('template_include', 'civicrm_wp_template_public');
}
}
function civicrm_wp_template_public($template)
{ return dirname(__FILE__) . DIRECTORY_SEPARATOR . 'civicrm-public-pages.php'; }create file wp-content/plugins/civicrm/civicrm.php:
<?php
/**
- The Template for displaying CiviCRM public pages.
- Please change this template file to accommodate your needs and/or theme requirements.
*
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php civicrm_wp_invoke(); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer(); ?>