Tag Info

New answers tagged

0

As per WP Code Snippet blog, it looks like this is one way: Add this code snippet to your functions.php file. // add async and defer to javascripts function wcs_defer_javascripts ($url) { if (strpos($url, '.js') === FALSE) { return $url; } if (strpos($url, 'jquery.js')) { return $url; } return "$url' async ...


0

Its already answered on this link <?php //To remove all script from the page function remove_all_scripts() { global $wp_scripts; $wp_scripts->queue = array(); } // to remove all stylesheet add_action('wp_print_scripts', 'remove_all_scripts', 100); function remove_all_styles() { global $wp_styles; $wp_styles->queue = array(); } ...


1

Depending on how your Galleria plugin is interacting with the attachment image filters, you should be able to inject your data attribute using the wp_get_attachment_image_attributes filter. Obviously, the attribute would be added for anything using wp_get_attachment_image(), but it will do what you're asking. /** * Filter attributes for the current ...


0

Just paste this in your functions.php file. It will automatically add jQuery in your theme. function wcs_scripts_styles() { wp_enqueue_script( 'jquery' ); } add_action( 'wp_enqueue_scripts', 'wcs_scripts_styles' ); WordPress automatically include jquery from it's location. You do not need to upload jquery on your theme. additionally you can also add ...


0

Doing anything without a "page-load" most definitely requires Javascript because your now venturing into the A-Synchronous (AJAX) territory and JQuery is a great library to use for this stuff. The most simple and straight forward of which is the $.post(...) method. You could then attach this send and receive AJAX call to either a shim of Javascript that ...


1

I found the solution to my problem was to change my_data.data.my_key to my_data.my_key. For example: $( document ).on( 'click', '#button', function() { var my_data = wp.heartbeat.getQueuedItem( 'my_handle' ); alert( my_data.my_key ); }); The queued data can be easily accessed now.


0

Filtrify doesn't actually use AJAX to get a new data set, it simply hides all of the elements which don't match your current filter. Because you already have a page displaying all books (for example) you are already pretty well set up to use Filtrify. The only extra step that you need to take is to add the data-genre attribute to each of your books (or ...


0

Wordpress and AJAX. First, you have to register and action, and link that action to a PHP function. In that function, you can use a custom WP_Query to return the posts for each genre. You will need to use javascript to create the avascript function executed when someone clicks and option from the dropdown, that function has to make a call to the action ...


1

I think you're looking for gform_enqueue_scripts which is simply a Gravity Forms specific version of the wp_enqueue_scripts hook. Either hook uses the wp_enqueue_script() function. That function can take a local script—usually using get_template_directory_uri() (theme), get_stylesheet_directory_uri() child theme), or plugins_url() (plugin) to reference the ...


0

Drop this into the file that is displaying the date (assuming you are using get_the_date): $month = date( 'F' ); $categoryIds = array(); $bannedMonth = 'September'; $bannedCategory = 13; $categoryArray = get_the_category(); foreach ( $categoryArray as $categoryObj ) { array_push( $categoryIds, $categoryObj->term_id ); } if ( $month != $bannedMonth ...


0

You are gonna need a PHP code like this, you can add it to the functions.php, or I would recommend creating a plugin. add_action('wp_ajax_nopriv_action_name', 'ajax_function'); add_action('wp_ajax_action_name', 'ajax_function'); function ajax_function(){ $post = get_post($_POST['post_id']); $response = array("content"=> apply_filters('the_content', ...


0

I think there is a 'more reliable' option. Relying on the menu item number is not garanteed to work if you migrate your code from development to production for example. If you turn the number into a setting it is getting better, but still not really good. An alternative could be to link to a non-existent anchor, like #olark, from your menu-item. This can be ...


1

You should solve your problem while moving toward a best practice while you're at it by using wp_enqueue_script(). This will likely solve your issues because it's domain agnostic. Start by moving your JS file(s) to a /js/ folder in your [child] theme or custom plugin. Then load your script like this... (snippets copied and adpated from Codex page). Theme ...


0

There is a item over these select boxes. In you css file search for element.style and remove it's position: relative; property. element.style { bottom: 0; left: 0; position: relative; top: auto; } That will fix this issue.


0

There are a few things going on with your functions.php file that may be the issue. You should be using wp_enqueue_scripts action to enqueue your script. The first parameter of wp_localize_script() should match the id of the file you've enqueued. You also need to add a no_priv version for your Ajax call if it needs to work for non-logged in users. Have a ...


0

Are there any Console js errors? The admin-ajax.php is Wordpress's built in way of dealing with ajax so you should probably do something like this, assuming .get() would also work: $.post(ajaxurl, data, function(response) { alert('Got this from the server: ' + response); }); http://codex.wordpress.org/AJAX_in_Plugins



Top 50 recent answers are included