Change in permalink structure made javascript cookie not work correctly

From comment: There is not enough information to answer your question. All your code is javascript, not PHP. Additionally, there is no function named “setCookie” or “getCookie” in javascript, and you don’t state what libraries you are using. The answer is most likely that your setCookie function is using the current page path (cookies have … Read more

No data received

Your code is wrong. You are confusing wp_enqeue_script function and wp_enqueue_scripts action. It should be: function theme_script(){ wp_deregister_script( ‘jquery’ ); wp_register_script(‘jquery’,get_template_directory_uri().’/sliderengine/jquery.js’); wp_enqueue_script(‘jquery’); wp_register_script(‘amazingslider’,get_template_directory_uri().’/sliderengine/amazingslider.js’,array(‘jquery’)); wp_enqueue_script(‘amazingslider’); wp_register_script(‘initslider-1′,get_template_directory_uri().’/sliderengine/initslider-1.js’,array(‘jquery’)); wp_enqueue_script(‘initslider-1’); } add_action(‘wp_enqueue_scripts’,’theme_script’);

How to retrieve a value from an input field in a media view template

After digging through the media modal code, I came up with the answer to my question: wp.media.controller.Custom = wp.media.controller.State.extend({ initialize: function(){ this.props = new Backbone.Model(); }, // called when the toolbar button is clicked customAction: function( controller ){ // get the value of a media view template form field using // this.props.get(‘key’), where ‘key’ is … Read more

Correct way to write jQuery functions in WordPress

As suggested in comments, this kind of error is caused by the fact that WordPress loads jquery in noconflict mode. The most common workaround is to wrap all functions in your script file: jQuery(document).ready(function($) { … scripts … } Another, more risky option is to switch off noconflict mode by starting the script file with … Read more

AngularJS with route and JSON API

Doublecheck if there’s a “nobase” error in your console. If so, according to the AngularJS documentation, and fix.io (credits for this answer go to the author of that post) the base tag is to the rescue. <html ng-app=”app”> <head> <base href=”https://wordpress.stackexchange.com/angular-wp/”> <title>AngularJS Demo Theme</title> <?php wp_head(); ?> Please note the “/angular-wp/” is the sub-context in … Read more

Custom post preview without saving

I found a nice way to do this using the preview_post_link filter, which allows you to rewrite the URL used by the preview operation. In my case I did something like: add_filter( ‘preview_post_link’, function ( $link ) { return ‘http://domain.com/mobile-preview/?src=”https://wordpress.stackexchange.com/questions/191918/. urlencode($link) .”%26admin_bar=false’; } ); When I click my preview button WordPress opens up my custom … Read more