Get Page Type (Category/Tag) Using AJAX

One thing you could do is set a variable in the archive.php like <script>var isArchive = true;</script>. Or in any template do if (is_archive()) { /* set the variable */ }. And then in the JS file do if (typeof isArchive != ‘undefined’) { } but there are probably way more elegant solutions that I’m … Read more

Pass the updated value of aid from form using ajax

I’m a bit confused – why the two submit buttons? And you’re outputting the same id multiple times (inside a foreach loop), which will choke jQuery. Try the following, using classes: $form = ”; foreach ( $results as $result ) { $value = esc_attr( $result->aid ); $form .= ‘<form method=”post” class=”aid-form”>’; $form .= “<input name=”aid” … Read more

Know which script/page is being called by ajax call

Open the website with Web Developer tools or Browser inspection tools ( Firebug )etc and then Run “Console”. Refresh your website and see the Ajax calls. Check the POST window in Ajax call to see action script. That’d tell you the exact function being called.

WordPress ajax not working in registration

Move this action ‘ add_action( ‘wp_ajax_nopriv_add_to_register’, ‘to_register’ );’ from load_scripts function(). // Load scripts function load_scripts() { // I called jquery.min.js and jquery validation from function.php, not from here wp_enqueue_script(‘test-reg’, get_template_directory_uri() . ‘/js/my-test-reg.js’, array(‘jquery’), ‘1.0’, true ); wp_localize_script( ‘test-reg’, ‘myAjax’, array( ‘myUrl’ => admin_url(‘admin-ajax.php’) ) ); } add_action( ‘wp_ajax_nopriv_add_to_register’, ‘to_register’ ); Replace reg_form() function with … Read more