Tag Info

Hot answers tagged

2

I have been investing some quality time (and headaches) with WP ajax so I understand where you are coming from. In all honesty, it could be anything from an error in your JS code or something completely bizarre, like: add_action('wp_ajax_UpdateMeta', 'UpdateMeta'); Should be changed to: add_action('wp_ajax_updatemeta', 'UpdateMeta'); ... to remove ...


2

I think the solution is amazingly simple here: You're just missing a single line of code in your ajax callback, namely: global $post; where I assume you're using: $post = get_post( $post_id ); The reason is that there's a global post check in the WP_Embed::shortcode() method. More details in my answer here.


1

your callback function must be like this: function cienna_show_slider_callback() { global $post, $product, $woocommerce; // just in case if your template file need this ob_start(); ?> <?php woocommerce_get_template( 'archive-product.php'); ?> <?php $output = ob_get_contents(); ob_end_clean(); echo $output; die(); }


1

WordPress is heavy out-of-the-box. If you only need the database, you'd be so much better off using mysqli or PDO and just connecting directly. Not to mention (in my opinion) PDO beats hell out of wpdb anyway, win win. the idea is to make use of the DB defines in wp-config.php without needing to store the username/password somewhere else Create ...


1

Maybe you have an image that was smaller or equal to the thumbnail size, if so, then no thumbnail will be created, and this.data[i].sizes.thumbnail will be undefined.


1

Add data-post_id attribute to checkbox and fill it with corresponding post ID. On click on compare button (link) retrieve all post ids from checked checkboxes with JavaScript (jQuery) Redirect to the comparision page with post IDs in url as GET parameters. This is just one scenario how you task could be done. PS your question is not related to WordPress ...


1

Before anything else: Be really sure that your endpoint to retrieve this information is reasonably secure. (e.g. using SSL and some authentication like a password) Leaking the information which plugins are installed on a site might offer a point of attack for hackers. I am not going to offer you a ready-made solution but outline two different ...


1

Updating the url via javascript, is not related to WordPress, however you just need to modify window.location.hash in your jQuery code. Regarding the usage of admin-ajax.php it is recommended way to do tasks via AJAX that need to load WordPress environment, instead of manually requiring wp-load.php. In your case you are sending a request to a regular ...


1

There isn't much point to distinguishing admin-ajax.php since it's essentially same file with same logic running for many many purposes. You are passing action data and hooking into respective action. So action is your identifier. If you are reusing same action and need to further differentiate — just pass more data with your GET/POST request and check for ...


1

The difference between the code you linked and your version, is that your post link has the permalink as the href value, where the original has just a hash. When you add a click handler to an anchor tag, it doesn't prevent what normally occurs when you click that link, it just executes the javascript and normal link behavior continues as it otherwise would. ...


1

You have to use the admin-ajax handler to do the AJAX call. Replace file.php in var url = "file.php"; with yoursite.com/wp-admin/admin-ajax.php?action=simple_ajax And in your plugin / functions.php file, add add_action('wp_ajax_nopriv_simple_ajax','process_simple_ajax' //for non logged in user add_action('wp_ajax_simple_ajax','process_simple_ajax' //for ...



Only top voted, non community-wiki answers of a minimum length are eligible