HTML5 Youtube wrapper works in jsfiddle but not in WP?

If you are talking about this, I can see it’s working. However, taking a look at the source code, I found you have two instances of jQuery. You might want to remove the first one found just below the opening <html> tag. It’s not only the improper way to enqueue jQuery, but may also conflict … Read more

Load jQuery inside Page Template

You should use the wp_enqueue_script() function to first enqueue your script and then wp_enqueue_scripts action hook to properly add your script to your footer or header of your theme. Also, you should take a look at conditional tags and how they are used to load functions/scripts/styles/etc on a conditional basis. So you would do something … Read more

Adding a character counter to the excerpt metabox

Ok, so I didn’t like the way that was written, so i slightly rewrote it with different syntax, and more readable structure. <?php // Add Character Counter to the Excerpt Meta Box function excerpt_count_js(){ if (‘page’ != get_post_type()) { ?> <script> (function($){ $(document).ready(function(){ if ( $(‘#postexcerpt’).length ) { var maxChar = 128; $excerpt = $(‘#excerpt’); … Read more

WordPress audio player causing js error, mediaelementplayer is not a function

I can think of two possible options – although I am not been able to test either right now. Option 1 In theory the cleaner one, as you detect if the mediaelementplayer plugin has loaded itself in the jQuery namespace: <!–Change WordPress Audio Player Default Volume–> <script type=”text/javascript”> jQuery(document).ready(function ($) { if($.fn.mediaelementplayer) { $(“audio”).mediaelementplayer({ success: … Read more

Automatic jQuery accordion from header tags

You can use shortcode function to do this. function accordion_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( ‘class’ => ‘accordion’, ), $atts ) ); return ‘<div class=”‘ . esc_attr($class) . ‘”>’ . $content . ‘</div>’; } add_shortcode( ‘accordion’, ‘accordion_shortcode’ ); In editor you wrap your content: [accordion] <h3>Headline 1</h3> <p>Content.. lorem ipsum</p> <h3>Headline … Read more

How to enable the content editor as a droppable target with jQuery-ui?

In the above example the following line: jQuery(“.myDiv”).find(“li”).each(function(){ should be: jQuery(“.keywords”).find(“li”).each(function(){ That should enable the list items to be dragged and dropped. To allow the items to be dropped on the TinyMCE textarea the following code works. $(‘#editorcontainer’).droppable({ drop: function(event, ui) { alert(‘dropped’); //NOW FIRES! //Dynamically add content tinyMCE.activeEditor.execCommand(‘mceInsertContent’, false, ‘New content.’); } });

Googles jQuery: Are There Avantages to Using It?

The big advantages are the Google CDN and the client side caching of the library. Your visitor will probably have a version of the jquery library in the browsers cache already, so he doesn’t have to re-download the script from the local version used by WordPress. One big disadvantage by including the library from the … Read more