Add conversion/tracking pixel to section for specific post

You can use the wordpress Conditional Tags You can add something like this to your functions.php file: is_single( ‘your-post-slug’ ) add_action( ‘wp_head’, ‘your_function_with_pixel’ ) There are a number of different conditional tags you can use. And your-post-slug can be substituted with the post id as well.

Javascript code inside “” in core WordPress files .php

These are Underscore Templates, handled by the wp.template() JavaScript function (source here) which takes in a template ID corresponding to a <script type=”text/html” id=”tmpl-{template ID}”> element containing such code and compiles it into a function. This function can then be executed with the variables used in the template in order to produce a string of … Read more

Help with enqueing scripts in footer after init action

If you enqueue the script to the footer while the page is being rendered (after the “wp_head” hook), you will have to manually add wp_print_scripts (or wp_print_footer_scripts) to the wp_footer action, like this: wp_enqueue_script( ‘jquery-gallery’, null, array( ‘jquery’ ), null, true ); add_action( ‘wp_footer’, create_function( ”, ‘wp_print_scripts( “jquery-gallery” );’ ) );

wp_enqueue_script adds only the first script

You gave each each script the same handle/id of ‘grid’ Try something like this. function banana_scripts() { wp_enqueue_script(‘grid’, get_stylesheet_directory_uri() . ‘/js/jquery.min.js’, null, null); wp_enqueue_script(‘grid2’, get_stylesheet_directory_uri() . ‘/js/main.js’, null, null); } add_action(‘wp_enqueue_scripts’, ‘banana_scripts’);

wp_enqueue_script with dependencies doesn’t work

This is a bug in WordPress. https://core.trac.wordpress.org/ticket/35873 As far as I can see, it can currently be fixed with https://core.trac.wordpress.org/attachment/ticket/35873/35873.3.patch, if you are reading this some time later, it has probably already been fixed for your WordPress version. As a temporary workaround, set parent dependencies to both child and grandchild. This way grandchild.js will not … Read more

How can I add my script to admin using script-loader.php?

I think you’e are only registering it with: $scripts->add( ‘user-profile-validator’, …) but not enqueueing it. Check e.g. how wp_register_script() is a wrapper for the WP_Scripts::add() method. Additionally add: wp_enqueue_script( ‘user-profile-validator’ ); in the relevant admin file to enqueue it or add it as a dependency for another enqueued script. Note that password-strength-meter is a dependency … Read more

Unable to load stylesheets and scripts to plugin settings page

The way to go was to use wp_enqueue_style() and wp_enqueue_script functions when admin_enqueue_scripts hooks. To register styles and scripts with wp_register_style and wp_register_script respectively is optional, but has some good advantages as nicely explained here. Here’s the working script: <?php /* Plugin Name: Awesome Slide Show */ // admin_init // ************************************************************************************************ function wp_ss_plugin_admin_init_cb() { // … Read more