Need help displaying data returned from custom widget
-
Please bear with me…I have a convoluted issue that’s not easy to explain…
I have a very large Multisite installation, and we use an external web application for searching it. I’ve created a widget that is simply an input box/submit button and we use that to search the DB.
Currently, in the form’s action, it calls a PHP file that sits in the wp-content folder. That’s bugged me for years.
What I’d like to do is display the results in the inner div of the theme.
Here is the pertinent code from the widget plugin:
public function widget( $args, $instance ) { global $custom_search_results_page; // <---- This is 'https://fqdn.tld/blogs/wp-content/custom_search_page.php echo $args['before_widget']; echo '<form method="post" class="searchform" action="' . $custom_search_results_page . '" >'; // I truncated the rest of the code
Here’s the basic code structure of the results page
<?php require_once( '../wp-load.php' ); get_header(); $source = "q=source:blogs"; $term = $_POST['fq']; if (isset($_POST['fq'])){ $term = $_POST['fq']; $start=0; $pageNum = 1; } if (isset($_GET["fq"])) { $term = $_GET["fq"]; $start = $_GET['start']; $pageNum = $_GET['pageNum']; } $term = urlencode($term); dhg_return_results( $term, $start, 10, $page_number, $instance ); // ^ that function displays the results neat and pretty
My question, I guess, is how do I do this the “WordPress way?” It basically works now, but I know it can be done better…just not sure how.
- The topic ‘Need help displaying data returned from custom widget’ is closed to new replies.