0

Here is my current plugin code

<?php
/*
Plugin Name: Site Plugin for this site
Description: Site specific code changes for this site
*/
function remove_sf_actions() {
    remove_action( 'sf_before_content', 'sf_header_widget_region', 10 );
}
add_action( 'init', 'remove_sf_actions' );
?>

I have tested this and it removes the sf_header_widget_region from each page on the website. What I would like to do now is show sf_header_widget_region on the homepage only and remove from all other pages.

I have tried wrapping the line of code in a conditional is_front_page function but it does not seem to work

  • Is your homepage a static page or your latest posts? – Jacob Peattie Jun 28 '18 at 12:12
  • My homepage is a static page – J12 Jun 28 '18 at 12:25
0

I use this code and now it works. I think using wp-head instead of init was important in the add_action parameter:

function remove_sf_header_widget_region() {
    if(!is_front_page()){
    remove_action( 'sf_before_content', 'sf_header_widget_region', 10 );
    }
}
add_action( 'wp_head', 'remove_sf_header_widget_region' );
  • It's likely that sf_header_widget_region hadn't been hooked yet, at init. You can't unhook actions before they're hooked. – Jacob Peattie Jun 28 '18 at 13:43

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.