why is my main.js not loading?
why is my main.js not loading?
why is my main.js not loading?
The problem was caused by another method inside the class: public function create_cart_id() { if( is_user_logged_in() ) { $this->create_logged_in_cart_id(); }else { $this->create_non_logged_in_cart_id(); } return $this->cart_id; – adding that line solved the problem } This method generates the $cart_id, but it didn’t return its value, so it was not accessible from outside and returned null.
How to paginate Ajax result
AJAX action returning empty posts array?
The reason that your idea doesn’t work is, get_post returns a post object, not an array (if not set manually). This is a quote from WordPress code reference: When $output is OBJECT, a WP_Post instance is returned. Which is the default output type for get_post(). If you need to implement an array of data and … Read more
You can start by trying this. 1. Change this <span class=”id_53″>Display Post Image</span> to <span class=”id_53″ data-id=”53″>Display Post Image</span> 2. Create you js file $(function () { // click event example $(‘.id_53’).on(‘click’, getThumb); // call the ajax function getThumb() { $.post( ‘http://path/wp-content/themes/your-theme/ajax-file.php’ , ‘my_id=’+$(this).attr(‘data-id’) , showThumb ); } // get image source function showThumb(e) { … Read more
First things first. Do not you query_posts(). Use WP_Query instead, to prevent messing with the main query. Now, as for your question. WP_Query allows you to enter data parameters too. It even has a date query which you can check it out in the link I’ve provided. Instead of using Admin-AJAX, you can write a … Read more
How to trigger lost password email using REST API?
You can’t hook into AJAX in a template, because the template’s not going to be loaded by admin-ajax.php when the request is made. You need to hook into AJAX when the plugin is loaded. Since your hooks are defined in the class constructor (whether nor not this is a good idea is another issue), you … Read more
You have 2 ways to pass the theme name into the javascript You can pass it as a variable into it in case you are using Ajax. If you are using any php file you can use <?php bloginfo(‘template_url); ?> Let me know if you need any more help