How do I locally enqeue the mediaelement.js file into a wordpress theme

You need to init the MediaElement.js by doing- For video or audio tag- <script> // using jQuery $(‘video,audio’).mediaelementplayer(/* Options */); </script> And for custom div– <script> // JavaScript object for later use var player = new MediaElementPlayer(‘#player’,/* Options */); // … more code … player.pause(); player.setSrc(‘mynewfile.mp4’); player.play(); </script> Just have a look on MediaElement.js wesite. … Read more

Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?

WordPress.org does not have any hard requirements for code styles for plugins or themes. In the plugin guidelines, the relevant section is #4, “Keep your code (mostly) human readable.” Mainly it is about obfuscation. The most relevant line is this: We recommend following WordPress Core Coding Standards. Note the word recommend, there. This is not … Read more

Add external js file to footer with id

You can use the script_loader_tag hook function enqueue_validation_script() { wp_register_script( ‘validation’, ‘https://www.asd.in/script.php?id=3ff00a469474bbe71a9218a7f0377518’, array( ‘jquery’ ) ); wp_enqueue_script( ‘validation’ ); } add_action(‘wp_enqueue_scripts’, ‘enqueue_validation_script’); function add_id_to_validation_script( $tag, $handle, $src ) { if ( ‘validation’ === $handle ) { $tag = ‘<script type=”text/javascript” id=”3ff00a469474bbe71a9218a7f0377518″ src=”‘.$src.'”></script>’; } return $tag; } add_filter( ‘script_loader_tag’, ‘add_id_to_validation_script’, 10, 3 );

Appending a value to metabox before and after saving

I was able to get it working by adding this… jQuery(document).ready(function($){ var custom_uploader; var currentfiles = document.getElementById(‘my_file_URL’).value; var currentID = document.getElementById(‘my_file_ID’).value; ….. var urls = selection.map( function(attachment){ return attachment.url; }); var ids = selection.map( function(attachment){ return attachment.id; }); $( ‘#my_file_URL’ ).val(urls.join(‘,’)); $( ‘#my_file_ID’ ).val(ids.join(‘,’)); if(currentfiles != ”){ $( ‘#my_file_URL’ ).val(currentfiles + “,” + urls); } … Read more

Any tag pagination page (except the 1st page) loads index.php template instead of tag.php

Overall CODE issues: Your CODE is so wrong in so many ways that I shouldn’t even attempt to address them here. I suggest you study Official WordPress Theme Handbook properly before doing these sort of customizations. For the sake of the context, I’m ignoring other issues within your CODE and touching only the issues below: … Read more