Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save xlplugins/384b5a28ed22a627fcac8b6fb0f77168 to your computer and use it in GitHub Desktop.

Select an option

Save xlplugins/384b5a28ed22a627fcac8b6fb0f77168 to your computer and use it in GitHub Desktop.
Add JS code in header for specific sales page
add_action( 'wp_head', 'wffn_custom_script_on_landing_option_page' );
function wffn_custom_script_on_landing_option_page() {
global $post;
if ( is_null( $post ) ) {
return;
}
// Check if the post ID matches the specific sales page ID (replace 123 with your desired page ID)
$target_page_id = 104; // Replace with the sales page ID where you want the script to run
if ( $post->ID != $target_page_id ) {
return;
}
// Check if the post type matches the desired types
if ( ! in_array( $post->post_type, array(
//'wfacp_checkout',
//'wfocu_offer',
'wffn_landing',
//'wffn_ty',
//'wffn_optin',
//'wffn_oty',
), true ) ) {
return;
}
?>
<script type="text/javascript">
jQuery(document).ready(function () {
alert("Page loaded successfully!");
});
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment