Include jQuery plugin in WordPress

A better method is to use the built in WordPress hooks in your functions.php with conditionals if needed ( for instance to load it only on certain pages). For hooking into admin you can use admin_print_scripts for hooking into the front you can use wp_print_scripts or one of the many other action hooks. For example: … Read more

Best way to include jQuery and fire with script at bottom of container

You typically should use the jQuery version that’s built in. There are instances where you might want to use wp_dequeue_script(‘jquery’) and then add a different version of jQuery. Here’s the best way to add a script dependent on jQuery: function theme_register_scripts(){ wp_enqueue_script(‘jquery’); wp_enqueue_script(‘myscript-name’, get_bloginfo(‘stylesheet_directory’) . ‘/js/myscript.js’, array(‘jquery’)); } add_action(‘wp_print_scripts’, ‘theme_register_scripts’); The third argument of wp_enqueue_script … Read more

Combining media queries with image sizes

First off, kudos to this pretty cool solution. I think you’re on the right track and not sure how much more you could do. You could certainly replicate the above with PHP & CSS, thus not requiring jQuery. It would require you to have an array of your sizes and just loop through them. This … Read more

Not sure why wp_ajax isn’t working?

This is just a simple javascript issue. When your javascript that attaches the click behavior to the form is parsed, the form element doesn’t yet exist because it’s further down the page, so it doesn’t get attached. Either move the javascript below the form, wrap it in a jQuery(document).ready(), or use live. EDIT – $(‘#ajaxForms’).serialize(); … Read more

Script for initializing JQuery Masonry for WordPress

This executes, when the DOM has been constructed, before all content has been loaded $(document).ready(function(){ … }); $(function(){…}); // short form This executes, when all content has been loaded $(window).load(function(){ … }); This executes immediately, when it is first encountered by the browser (function(){ … })(); The latter is known as a self-executing anonymous function, … Read more

How can I check email exists via a jquery keyup()?

I would use an AJAX request to a PHP script that does the lookup, which might look something like this on the jQuery side after document ready: // jquery $(‘#email-input’).live(‘change’, function() { //ajax request $.ajax({ url: “email_check.php”, data: { ’email’ : $(‘#email-input’).val() }, dataType: ‘json’, success: function(data) { if(data.result) { alert(‘Email exists!’); } else { … Read more

How to get a value from PHP in Jquery through Ajax

You are passing ‘readen_color’ as the action parameter, but you’ve defined the ajax action as ‘mark_as_read’. Try this: $.post(ajaxurl, { action:’mark_as_read’, post_id: iPostId }, function (response) { console.log(response); }); And as for your PHP: add_action( ‘wp_ajax_mark_as_read’, array( &$this, ‘readen_color’ ) ); // Add no_priv if you want users not logged in to be able to … Read more

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