How to make ajax content indexable by search engines?

Any reasons you couldn’t put an anchor link to the actual page in your tab control? Then use jQuery to make sure it returns false and doesn’t “work” for normal visitors. In fact, that’s what the jQuery Tabs control page suggests: Tabs supports loading tab content via Ajax in an unobtrusive manner. The HTML you … Read more

Using wp_ajax and wp_ajax_nopriv hooks

It depends on what exactly you want to do. If you want to show just a short message, use the same callback for both. But if you need completely different objects and load different additional files depending on the log-in status, use separate callbacks. Basic example, probably not a recommended implementation. 🙂 class Ajax_Controller { … Read more

WP_LOCALIZE_SCRIPT doesn’t work

You have to use the correct handle: wp_localize_script(‘page_data’, ‘glr_dt’, $gallery_js_data_array); // Edit Your code is also wrong. What do you want to do in this line: ‘maxPages’ => ‘$gallery_max_load = $gallery->max_num_pages;’ You are assigning a string to maxPages. I guess you want it that way (or similar): ‘maxPages’ => $gallery->max_num_pages, Now, you can access the … Read more

Ajax call in wordpress not working for subscriber user in front site

For non-admin users to be able to use an ajax function, you need to also include a second hook using wp_ajax_nopriv So right after this: add_action(‘wp_ajax_add_category_bookly’, ‘add_category_bookly_callback’); you should include this: add_action(‘wp_ajax_nopriv_add_category_bookly’, ‘add_category_bookly_callback’);

Ajax is not working for logged out users

function add_ajax_actions() { add_action( ‘wp_ajax_nopriv_get_blog_items’, ‘get_blog_items’ ); } add_action( ‘admin_init’, ‘add_ajax_actions’ ); admin_init only runs when the admin area is initialised. Logged out people can’t access wp-admin, so add_action( ‘wp_ajax_nopriv_get_blog_items’, ‘get_blog_items’ ); never runs. Move the add_action call out of that function and remove the add_ajax_actions function and it should work. Have you considered using … Read more

Confused on AJAX submit form through page template

<form action=”<?php echo get_template_directory_uri() . “/validation.php”; ?>” id=”contactForm”> 😱 So I’ll outline the basic fundamentals, so you have a framework to move forwards with Fixing Admin AJAX So I’ll cover this very briefly as it’s not the crux of my answer, but would be useful: Add a hidden input field named action rather than adding … Read more

How wp_ajax_nopriv since WordPress 3.1

Site you referred to is likely being updated in automated fashion. The reason it wrongfully claims that action is deprecated is because: you are looking at page for wp_ajax_nopriv_{$_POST[action]} while in recent WP versions actual code is wp_ajax_nopriv_{$_REQUEST[action]} (also documented on that site). So action is not deprecated, its functionality is not changed (only the … Read more