php ajax problem – weird 301 responses!

I’m guessing the page your calling executes an wp_redirect with a 301 response somewhere. Dont really have an answer for you but maybe you can try the following. Ajax does not know what type of page your calling from and there might be some strange query_vars loaded that trigger a redirect. Your using a permalink … Read more

Tags in WordPress 3.2

I believe this to be an issue with a jQuery conflict. Since version 3.2 of WP jQuery has been updates. There might be other plugins you are using that doesn’t play nice with the new jQuery version which is then triggering a JS error, thus stopping the tag/AJAX functionality from working. Try disabling all your … Read more

enqueue the scripts

Add your script to a file inside your Theme root, e.g. /js/my-script-name.js. In functions.php, put add a function to enqueue your script: function mytheme_enqueue_some_script() { if ( ! is_admin() ) { $scriptsrc = get_template_directory_uri() . ‘/js/my-script-name.js’; wp_register_script( ‘my-script-name’, $scriptsrc ); wp_enqueue_script( ‘my-script-name’ ); } } Then, hook that function into the wp_enqueue_scripts hook: add_action( ‘wp_enqueue_scripts’, … Read more

Passing JSON-encoded HTML from WordPress to JavaScript

While it’s not exact answer to your precise question, I agree with method suggest in comment. Just skip trying to stuff data into single dimension and make use of l10n_print_after argument instead. See pass object/JSON to wp_localize_script question and answer there.

Add a Fancybox automatically to post type “post” images

Here is the code i use in my site, which loads all images under an anchor tag to fancybox add_action(‘wp_footer’,’auto_fancy_box’); function auto_fancy_box(){ if (!is_single() && !is_page()) return; ?> <SCRIPT TYPE=”text/javascript”> jQuery(document).ready(function(){ jQuery(“.post_content”).find(“a:has(img)”).addClass(‘group’); jQuery(“.post_content”).find(“a:has(img)”).attr(‘rel’,’group1′); jQuery(“a.group”).fancybox({‘transitionIn’:’elastic’,’transitionOut’:’elastic’,’speedIn’:600,’speedOut’:200,’overlayShow’:false}); }); </SCRIPT> <?php } just change the .post_content to your post content container jQuery selector.

wp_verify_nonce not working

I don’t know I just submitted the ticket on track. I was using get_current_user_id() and it modifies the wp_create_nonce behavior. Sinces wp_create_nonce uses wp_get_current_user() I think there is the problem.

Accept AJAX call with serialized form data

When working with AJAX and Forms in WordPress I like to code in the ajax action to the form so serialize works out of the box. Actually I wrote an article on this last year: https://webdevstudios.com/2015/02/12/handling-ajax-in-wordpress/ But, you’re here for answers, not a blog article, so here’s the brief part of it. You have three … Read more

Need To Deregister Scripts Via Functions.Php

Ok the following does work now, I think it was a caching issue and I forgot to add the correct priorities Using the priorities now it definitely works and I also managed to de-register Buddypress scripts add_action( ‘wp_print_scripts’, ‘de_script’, 100 ); function de_script() { wp_dequeue_script( ‘jquery’ ); wp_deregister_script( ‘jquery’ ); wp_dequeue_script( ‘bp-legacy-js’ ); wp_deregister_script( ‘bp-legacy-js’ … Read more