WordPress wp_enqueue_script only adds text to top of page source

You need to wrap your text with <?php and ?>. Like this: <?php function my_scripts() { wp_enqueue_script( ‘jquery’ ); wp_register_script( ‘parallax’, get_template_directory_uri() . ‘/parallax.js’, array( ‘jquery’ ), NULL, true ); wp_enqueue_script( ‘parallax’ ); } add_action( ‘wp_enqueue_scripts’, ‘my_scripts’ ); ?> Otherwise, the PHP parser never sees it – and it’s sent as text to the browser. … Read more

Inherit scripts from parent to childtheme

Thats because parent theme using get_stylesheet_directory_uri() to call script. By this function it is searching for file in your child theme folder (bcause child theme’s style.css is using by active theme) where no such files present. This function search those theme folder whose style.css file is using in active theme. Right now your child theme … Read more

Why does Thickbox jQuery load on my site?

You are perfectly right, ThickBox is old and it supposes to be present in admin Dashboard only, but beeing able to change this kind of behavior makes WordPress great (and sometimes not). Every theme or plugin can actually call this library for his help with the wp_enqueue_script(‘thickbox’) function or it can use it as a … Read more

ACF Pro with SlickJS [closed]

You should be using wp_enqueue_scripts instead of wp_footer to load your styles and scripts. Try adding jQuery as a dependency for slick-init.js and that should work. I suspect that the slick-init.js calls on the styles to create the specified look you want.

jQuery selectable() function won’t work in wordpress

I always refer to to this blogpost about how to including jQuery code in WordPress. It shows you how to use noConflict within your javascript-code. var $j = jQuery.noConflict(); $j(function(){ // YOUR CODE HERE } } Also make sure that the jQuery library is included on the frontside of your WordPress installation with the wp_enqueue_script-function. … Read more

how to get permalink

To get a permalink you need to use get_permalink(). Just pass the ID of the post or leave it blank to get the current page in the Loop. wp_localize_script () will render PHP variables on the page that are consumable by JS through a global object that you define. PHP // Register the script wp_register_script( … Read more

How to load jQuery in TOP of wp_footer?

To properly enqueue jQuery, it’s usually done with wp_enqueue_scripts, there’s no need to load it from cdn as jQuery library are provides in the wp-includes folder of WordPress. Only wp_enqueue_script(‘jquery’); is required. add_action(‘wp_enqueue_scripts’, ‘replace_jquery’); If you really want to replace jQuery with the cdn link, it’s better to register and enqueue it with this function.