Create URL with parameter for JQuery toggle status

You need to process 2 scenarios: When page is loaded with #espanol hash When button is clicked //check for #espanol hash and toggle on page load spanishByHash(); //process toggle on click event $(‘.js-spanish-toggle’).on(‘click’, function() { hashToggle(); spanishToggle(); }); function spanishToggle() { $(‘.js-spanish-toggle’) .find(‘button’) .toggleClass(‘active’); $(‘.js-spanish-toggle’) .parents(‘.spanish-container’) .toggleClass(‘is-spanish’); } function hashToggle(){ if($(location).prop(‘hash’) === ‘#espanol’){ $(location).prop(‘hash’,”); }else{ … Read more

combining js scripts from a js newb [closed]

The jQuery(document).ready event is called when the document DOM is ready to be manipulated. In earlier days we attached all our handlers to document.load, but this waits until all images are loaded too, and most of the time one doesn’t need that. There are three equivalent ways of hooking into this event, and a fourth … Read more

WordPress Jquery Confliction with Plugin

There are currently two copies of jQuery loaded on site: In header there is jQuery bundled with WordPress, likely requested by some plugin. In footer there is jQuery from Google CDN, likely added by your code? Obviously this is one too many. There are couple of ways to handle it: If you are fine with … Read more

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.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)