Querystring data gets truncated

As you have asked wether or not you have done the url encoding for the ampersands right, then my answer is: No. You are calling a javascript function, you’re not outputting something as x(ht)ml. You therefore do not need to encode & as &. The function is expecting a URL not a string that contains … Read more

Localize variable for multiple Shortcodes

Your ploblem is that wp_localize_script print to the html markup a javascript object similar to: var slider = {“id”:”a_unique_id_here”}; if you call it more times, e.g. using more shortcodes in same page, whati is printend in html markup is var slider = {“id”:”a_unique_id_here”}; var slider = {“id”:”another_unique_id_here”}; var slider = {“id”:”third_unique_id_here”}; so you are overwriting … Read more

possible to make sections in theme customizer sortable and saveable at publish button clicked?

Simple tutorial – How to sort customizer sections in the panel and add order to theme. 1. You must use prefixes to do this because customizer don’t support custom classes. ctmss_panel_ – for panels ctmss_section_ – for sections ctmss_hidden_ – for hidden sections that has a input with values 2. Add panel to the Customizer … Read more

Best approach for loading a sidebar Only if the screen max-width is >900px?

On my website I load the recent comments per AJAX for window sizes above 480px: if ( 480 < jQuery(window).width() ) { jQuery(document).ready( function() { jQuery.get(‘http://toscho.de/?rc’, function(data) { jQuery(data).insertBefore(‘#inner’); } ); } ); jQuery(‘#posts’).after(‘<div class=clear>&#160;</div>’); } This code is quite old and not very elegant. But it may give you a hint for the right … Read more

Unbind postbox click handler

You can just put the necessary javascript in a file and enqueue it on the necessary page: add_action( ‘admin_enqueue_scripts’, ‘add_admin_scripts’, 10, 1 ); function add_admin_scripts( $hook ) { //You can globalise $post here and enqueue the script for only certain post-types. if ( $hook == ‘post-new.php’ || $hook == ‘post.php’) { wp_register_script( ‘my_js_handle’,’/path/to/js/my-js-file.js’,array(‘jquery’),1,true); wp_enqueue_script(‘my_js_handle’); } … Read more

WordPress Featured Post Slider

This is one of those things you probably have to do yourself, even though there are some slider plugins, they are difficult to customize. Using a jquery slider is pretty straightforward, they are usually just controlled with ID’s and CLASS’s, so you can wrap any WordPress code, for instance a wp_query (for featured posts). toscho’s … Read more

Best Way to Include Scripts on a Specific Template Page

The following (in your theme’s functions.php) will register your script, and set jQuery as a dependency. So when you enqueue it, jQuery will also be enqueued. function my_scripts_method() { // register your script location, dependencies and version wp_register_script(‘my_custom_script’, get_template_directory_uri() . ‘/js/custom_script.js’, array(‘jquery’), ‘1.0’ ); } add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’); You can then enqueue your script one of … Read more