Hello,
I’m trying to bring most of my PHP code from one of the plugins I have used before to the new Elements->Hook which as I understood can execute PHP.
The code I’m playing with is simple JetPack “Related posts” removal which works perfectly using the old plugin to execute php but doesn’t work with Elements->Hook.
<?php
function jetpackme_remove_rp() {
if ( class_exists( ‘Jetpack_RelatedPosts’ ) ) {
$jprp = Jetpack_RelatedPosts::init();
$callback = array( $jprp, ‘filter_add_target_to_dom’ );
remove_filter( ‘the_content’, $callback, 40 );
}
}
add_action( ‘wp’, ‘jetpackme_remove_rp’, 20 );
?>
The Hook I’m creating has options like:
Hook: before_header
Execute Shortcodes: On
Execute PHP: On
Priority: 0 or 100 (doesn’t work with both)
Display rules Location: Entire Site
But the code doesn’t work. What am I doing wrong? Btw I don’t insert this hook as shortcode in to posts or pages. I’m thinking if Location is set to: Entire Site the code should run automatically?
Thank you,
Inna.