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 7564535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:55:58+00:00 2026-05-30T13:55:58+00:00

All, I’m trying to use the do_shortcode function. I have the following jQuery to

  • 0

All,
I’m trying to use the do_shortcode function. I have the following jQuery to call a post function:

category = $("#past_vendor_category").val();
search_term = $("#past_vendor_name").val();

$.post("http://localhost/wordpress/wp-content/search_past_vendors.php", { category: category, search_term: search_term }, function(results){
    $("#past_vendor_search_results").html(results);
});

Which then calls this PHP file:

<?php
global $shortcode_values, $theLayout;
include "config.php";
$category = mysql_real_escape_string($_POST['category']);
$search_term = mysql_real_escape_string($_POST['search_term']);

$qry = "Select wp_posts.ID, wp_posts.post_name, wp_posts.post_title, custom_vendor_info.city, custom_vendor_info.city
from wp_posts
join custom_vendor_info on wp_posts.ID=custom_vendor_info.post_id
join wp_term_relationships on wp_posts.ID=wp_term_relationships.object_id
where wp_posts.post_title like '%$search_term%' and wp_term_relationships.term_taxonomy_id='$category'";
$result = mysql_query($qry);
$resultrows = mysql_num_rows($result);
$x=0;
if($resultrows>0){
    $show_results = '<br>';
    while($resultset = mysql_fetch_array($result)){
        if($x==0){
        $show_results .= '<div class="vendor_search_result"><span class="vendor_search_result_name"><a href="'.$resultset['post_name'].'">'.$resultset['post_title'].'</a></span><span class"vendor_search_result_button">'.do_shortcode("[button]Text[/button]").'</span>';
        }else{
        $show_results .= '<div class="vendor_search_result"><span class="vendor_search_result_name"><a href="'.$resultset['post_name'].'">'.$resultset['post_title'].'</a></span><span class"vendor_search_result_button">'.do_shortcode("[button]Text[/button]").'</span>';
        $x=0;
        } 
    }
    echo $show_results;
}else{
    echo '<br>Sorry, there were no search results for "<b>'.$search_term.'</b>". Please try again!';
}
?>

This file is not inside a WordPress page so I’m getting the error message:
Fatal error: Call to undefined function do_shortcode() in D:\My Documents\xampp\htdocs\wordpress\wp-content\search_past_vendors.php on line 19

Any idea how I can use the do_shortcode outside of a WordPress page?

Thanks

  • 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-05-30T13:55:59+00:00Added an answer on May 30, 2026 at 1:55 pm

    The do_shortcode function depends on the global state of wordpress. As in your example code you don’t load wordpress, it’s not available.

    I suggest you create yourself some plugin that offers an Ajax interface and that is then processed by the default wordpress Ajax backend.

    See 5 tips for using AJAX in WordPress (original article archived) for a step-by-step description how you can bind your PHP functions to Ajax requests properly.

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

Sidebar

Related Questions

All, Say I have the following bit of code: select: function(start, end, allDay) {
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All, I'm trying to use the jQuery Form Validator (http://docs.jquery.com/Plugins/Validation). However I'd like to
All, I have the following code: $fetch = mysql_query(SELECT * FROM calendar_events where event_status='booked'
All the examples of use and tutorials I have found on beginBackgroundTaskWithExpirationHandler: show how
All, I have the following class so to check to see if the form
All, Say I have the following divs: <div id=rotate_container> <div class=reviews id=item1>This is item
All, I have my application setup so that i can use a specific username
All, I currently have two projects that are under SourceSafe that I am unable
I am trying to understand how to use SyndicationItem to display feed which is

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.