Seperate plugin and theme files


I am in desperate need of help, regarding the following issue:

I need to establish an API Connection to Salesforce, so that a user can search and retrieve certain data out of Salesforce.
I thought, that a plugin would be the best choice, so that the functionality is not dependent on a certain theme.

Here comes my issue:
I want the search form to be added via short-code, so that it can be reused. So far so good.
Then I gave the form an action attribute to call another php file, which retrieves the entered data to search for, and list the search results.

Now when I call that second file, I get the error Call to undefined function get_header().
But I need the header of the selected theme to be displayed on that page, so that the whole website has the same look and feel.

It seems, as if I am going horribly wrong with my approach.

My file structure looks as follows:

                 -- myTheme


And this is how I add the shortcode for the form to be displayed:

 * @return string
function add_search_form() {

    <div class="col-sm-6 col-md-offset-3 d-flex justify-content-center text-center form-column">

    <form class="wdv_search_form w-75 mt-3" method="get" action="wp-content/plugins/myPlugin/views/page-results.php">
        <div class="mb-2">
            <input type="text" class="form-control text-center" id="searchByLocation"
        <div class="mb-2">
            <input type="text" class="form-control text-center" id="searchByName"
        <div class="mb-2">
            <select name="countryChoice" class="text-center">
                <option value="EN">England</option>

        <button type="submit" class="btn btn-transparent text-light mt-3">GO</button>


    echo $html;

add_shortcode( 'wdv_search_form', 'add_search_form' );

Is my approach right and what would be best-practice for my use-case?

Fewture Webdesign 2 years 2022-06-22T06:56:35-05:00 0 Answers 0 views 0

Leave an answer