I am writing a plugin to display information from the database. There is a function:

function show_list_oil_filters($content) { global $wpdb; $excel_out = $wpdb->prefix.excel_out; $results = $wpdb->get_results("SELECT DISTINCT `Brand` FROM $excel_out"); foreach ($results as $marca) { echo do_shortcode("[filteroption val='".$marca->Brand."']"); } return $content;} 

This function selects and displays the result of the shortcode on a static page.

Shortcode code:

 function filteroption_func_handler_oil_filters($att) { /*Для примера*/ return "<option value='" . $att['val'] . "'> Received attribute: " . $att['val'] . "</option>";} 

Information is displayed on the static page, but not in the right place.

How to display the received information in the right place in the <select></select> on a static page?

    1 answer 1

    Where you take the shotcode, there is a replacement.
    I suppose that the show_list_oil_filters function works on the the_content filter. If so, its code may be as follows:

     function show_list_oil_filters($content) { global $wpdb; $excel_out = $wpdb->prefix.excel_out; $results = $wpdb->get_results("SELECT DISTINCT `Brand` FROM $excel_out"); echo '<select>'; foreach ($results as $marca) { echo do_shortcode("[filteroption val='".$marca->Brand."']"); } echo '</select>'; return $content; } 

    For a more detailed answer and solution, more information is needed.