Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8033147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:36:22+00:00 2026-06-05T01:36:22+00:00

I wanted to know if there is a way to use function like query_post()

  • 0

I wanted to know if there is a way to use function like query_post() in an ajax call ?

Let’s say i’m calling the file _inc/ajax.php

I want to be abble to use the wordpress functions, but i don’t know why.
Can someone help me for that ?

Thanks a lot 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:36:23+00:00Added an answer on June 5, 2026 at 1:36 am

    WordPress provides an Ajax Url that you should use along with a complete Ajax API.

    You need to create a jQuery function.

    Example:

    jQuery(document).ready(function($) {
    
        var data = {
            action: 'my_action',
            whatever: 1234
        };
    
        jQuery.post(ajaxurl, data, function(response) {
            alert('Got this from the server: ' + response);
        });
    });
    

    The ajaxurl var is always available on the admin side. If your using it on the front end you need to define it.

    Then a PHP function where you can run your query. The PHP function must get attached to the wp_ajax_your_action action.

    Example:

    add_action('wp_ajax_my_action', 'my_action_callback');
    
    function my_action_callback() {
        global $wpdb; // this is how you get access to the database
    
        $whatever = intval( $_POST['whatever'] );
    
        $whatever += 10;
    
            echo $whatever;
    
        die(); // this is required to return a proper result
    }
    

    The wp_ajax_your_action action is for admin if you need to use it on the front end the action would be wp_ajax_nopriv_your_action

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to know if there's a way I can bind an Asp.net Ajax
I wanted to know if there is way to log the mysql queries in
I wanted to know if there is any way to synchronize (or exchanging files)
I just wanted to know if there is a way on how to remove
hi guys I wanted to know, is there a way to not display my
Python newbie here and wanted to know if there was a way to combine
I wanted to know if there's any way I could output HTML after extracting
Is there any way in C# to save a function call for later invoking?
I wanted to know if there are still available plugins compatible with groovy that
I wanted to know whether there are bitwise operators for Bitvector32 that operate in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.