New answers tagged

0

Below you will find some things you might want to consider regarding post types. But one note up front: Every WP_Query is done for the current user. If you do not see what you expect, try it with a logged in admin user first. This way you can easily check if the problem is a capability issue. About the post status you seem to be querying from the DB: ...


1

This is happening because a separate nonce with the action wp_rest is not being sent by the server to the client and received back from the client in an HTTP request header called X-WP-Nonce with every REST request. To get this working, you will have to generate a nonce like this: wp_create_nonce('wp_rest') ...and provide it to the client making the rest ...


1

@Rup's comment above led me to the answer; my wp-ajax request was functioning fine, but my incomplete understanding of jquery's $(this) selector meant that I was targeting the last item clicked with the success response each time. This question can now be closed.


1

If i'm not sure if i have misunderstand your question might, yes you need to send a post request to POST /wp/v2/users api. That should do the trick i dont think programming language have issue on this. I believe you should decide how post submitting flow should be affecting.


0

You are making direct calls to a PHP file in your theme, this is why you have the problem. Because WordPress didn't handle the request, your file did, none of WordPress is loaded, and none of the plugins. There are also lots of security issues with this approach. If you need to make an AJAX request, make it to a REST API endpoint. For example, here I ...


0

I discovered Infinite Scroll has an updateurl function: var nextURL; function updateNextURL( doc ) { nextURL = $( doc ).find('.tax-pages a.next').attr('href'); } // get initial nextURL updateNextURL( document ); // init Infinite Scroll var $container = $('#main').infiniteScroll({ // use function to set custom URLs path: function() { return ...


1

In short, you should use response.data.messages. And that's because wp_send_json_success() will send a JSON response (an object) with the property data set to whatever that you passed to the function. wp_send_json_success( 123 ); // In JS, response.data would be an integer. I.e. response.data = 123 wp_send_json_success( array( 'foo' => 'bar' ) ); // In ...


1

Your hook name uses an underscore: add_action( 'wp_ajax_save_form', 'save_form' ); add_action( 'wp_ajax_nopriv_save_form', 'save_form' ); But your action uses a hyphen. action: 'save-form' These need to match: action: 'save_form' Also, your AJAX callback appears to be in apps/save_signups.php, but you are only requiring that file inside the ...


1

So, The ideal way to do it is to have some identifier and save it in Database. But this can only happen if either user is logged in, in which case we can use, user meta to save the number of clicks, or we can use User IP and save it as transients. User IP again shall mean, that you need to get into hassles of policies and all, as IP is considered private ...


1

Okay, So I had asked you few things in comments for your question, you are yet to answer them, But I shall begin with some things. So I assume that 1.) for 10 posts, each post has 1 download link unique to it, 2.) each link has the class 'gotocls' 3.) Downloading stuff is working correctly, meaning I just need to get it to hide/show when necessary. 4.) each ...


1

Use below code to get the 'pdff' value: $url_components = parse_url($ark[0]); // Use parse_str() function to parse the // string passed via URL parse_str($url_components['query'], $params); // Display result echo $params['pdff'];


0

I found the solution: The page was missing vc_carousel.min.css transition.min.js and vc_carousel.min.js With these files loaded, the corousel works fine


1

A response is needed from php side after sending an AJAX call. // ... rest of the code if ( is_user_logged_in() ) { wp_send_json_success(); } else { wp_send_json_error( null, 403 ); } // ... rest of the code And then in your JS code add a new check for jqXHR.status == 403 error. Documentations: wp_send_json_success wp_send_json_error


0

So, In question you stated that the code needs to execute when the thickbox closes. We can solve your problem with 2 approaches, first is to check for thumbnail url change every x seconds, and then update the img if the url changes, this works good but its data heavy, so I cant recommend that. Second method is, to have the event of thickbox close to be used, ...


0

The following test is carried to find out why. Because the test will touch the core source code. Only do it if you feel comfortable to do so. Testing environment PHP 7.4.9 WordPress 5.5 No plugin and then tried 1 plugin to stop heartbeat. (make sure ajax is not interfering the experiment) default theme No 404 error (404 error will lead to other recalling of ...


0

1.) First, when creating a shortcode, you must return data, not print. 2.) Yes, you must explicitly specify the post id, print the id in the button or form of your shortcode, you can also use the shortcode attributes to generate a button for a specific post (See example) Your shortcode code should be like this: function lsmg_pdf($args) { global $post; ...


1

There are a number of problems, but the biggest and most important is this: 'meta_query' => array( The post meta table is optimised for finding keys/values when you already know the post ID. But you've asked WP_Query to do the reverse. This means the query gets more and more expensive/slow as your site grows, and the database has to do a lot of heavy ...


0

It is not right location.href = "#modal"; when you need to change hash you need to use window.location.hash = 'modal' but you have another problem! You need to initialize your plugin and use its api Instead of this location.href = "#modal"; you need to use: var inst = jQuery('[data-remodal-id=modal]').remodal(); inst.open()


0

As per confirmation from @Jacob Peattie, my understanding is now this (if it is helpful to future readers). AJAX calls to a WordPress plugin method exist in a totally separate context (separate requests) from the object instance created when a WordPress plugin's PHP files are interpreted when a page is loaded. Therefore, a property that is given a specific ...


2

I usually use CSS classes to control AJAX requests affecting a specific element. This way you can prevent unwanted AJAX requests on that element, while other AJAX requests may still be triggered, being bound to other elements. $('.slot').on('click', 'a.book', function(e) { e.preventDefault(); // Check if doing ajax if($(this).hasClass("...


2

You can use two approach to prevent the user to click on your elem before complete the ajax fully. 1.Display loader and block that element so that no one can excute it until the ajax complete. 2.use a global var isAjaxProcess = false; now in your code make a condition block If(isAjaxProcess === false) { isAjaxProcess = true: Your ajax code goese here. And ...


Top 50 recent answers are included