Why does my media selection script write to ONLY the first input field?

this problem is because of the first “if”, the good text field in only set the first time to change that, you can add a “data” arguement in HTML and change the JavaScript code like that (look the modification in meta_image_frame.on(‘select’…) (function($) { ‘use strict’; $(function() { var meta_image_frame; function saveImage(e, uiElement) { e.preventDefault(); if … Read more

wordpress ajax upload media not working

This looks like the access to admin-ajax.php is forbidden (error 403). For some reason, many security plugins are preventing access to admin-ajax.php, even with this file being essential for WordPress to work correctly. If you use some security plugin, check out if it is maybe blocking admin-ajax.php. Check if admin-ajax.php is blocked in .htaccess file … Read more

Pass jquery variable to php function and run it

Tested this locally and found the issues. When you reg/enq the JS, you need to localize the script. This is your chance to pass anything from PHP to the script. In this case, you should, at minimum, pass the WP ajax url like this: wp_localize_script( ‘my_js_library’, ‘my_local_var’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ) ) ); … Read more

Orderby post__in Not Working Correctly?

If you look at the source of the Ajax Load More plugin, you can see a number of filters you can use to modify the query. You’ll likely want to use the alm_modify_query_args filter like so: $in_array = [ 115, 123, 66, 64 ]; add_filter( ‘alm_modify_query_args’, function( $args ) use ( $in_array ) { $args[ … Read more

Target a specific page/template in jQuery

Approach 1 Use the body class. all templates will have a class representing them. ie: body.archive, body.single, body.home, etc. It will even have specific tax/post type classes for more granular control. Wrap your js function in something that checks for that body class. The following should do the trick: jQuery if ( $( ‘body’ ).first().hasClass( … Read more

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