I am trying to add infinite scroll functionality into my Wordpress theme.

I started my exploration of infinite scroll in Wordpress by going here and here.

My question is, I don't understand the codex code, and I also don't understand why it appears that Jetpack's infinite scroll circumvents //calling admin-ajax as explained in their source code.

In Jetpack's implementation, I don't see any wp_ajax_nopriv() calls.

I also really don't understand why I could check if_admin() if the point is that the nopriv() runs for unauthenticated users.

if ( is_admin() ) {
    add_action( 'wp_ajax_my_frontend_action', 'my_frontend_action_callback' );
    add_action( 'wp_ajax_nopriv_my_frontend_action', 'my_frontend_action_callback' );
    add_action( 'wp_ajax_my_backend_action', 'my_backend_action_callback' );
    // Add other back-end action hooks here
} else {
    // Add non-Ajax front-end action hooks here

I've employed infinite scroll in a custom PHP application before, and it was very easy, but this is currently lost on me.

I simply want to understand how to generate an ajax url to the backend to connect to a function that will handle the output for me, by returning data to the view. How do I go about doing that for unauthenticated users?

1 Answer 1


is_admin() runs when you are logged in as admin in the backend. So you need to do !is_admin() to run for normal users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.