Migrating from code-snippet | WordPress.org

[ad_1]

Hi

I am thinking of migrating from code-snippet to your plugin.

I was testing one of php scripts that i have but it is not working somehow, maybe some lines to be cleaned up, not sure.

<?php
add_action( 'wp_head', function () { 
if (is_page ( array( '93285','93389' ))) {
?>
<script>

	jQuery(document).ready(function() {
		
		if ((window.pageYOffset) > 74) {	
    		jQuery('header.site-header.site-header--bb').css('background-color','white');		
 		}		
	
	});
	
	jQuery(document).ready(function() {
		window.onscroll = function() {
			var yposition = window.pageYOffset 	
			if ((yposition) < 74) { 
				jQuery('header.site-header.site-header--bb').css('background-color','#ffffff38');			
			}
			else {
				jQuery('header.site-header.site-header--bb').css('background-color','white');		
			}		
		}
	});
</script>

<style>
	.site-header {
    background-color: #ffffff38;
}
</style>

<?php } });

add_action( 'wp_enqueue_script', function () {
	wp_enqueue_script( 'jquery' );
} );

Can you guide me what to be adjusted?

One suggestion tho

Can you add a sample code for each different types (php, javascript, universal, html, block..) for beginners like me to get some ideas how it should look like?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer