Created
April 15, 2018 18:59
-
-
Save nixonmedia/dc64901527d99bb609825e7510aee7b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$output = ''; | |
$fields = wcf_get_form_search_values($id); | |
$settings = wcf_get_form_search_settings($id); | |
$columns = $settings['columns_per_row'] != '' ? $settings['columns_per_row'] : 3; | |
$template_loop = 'wcf-loop'; | |
if ($settings['search_type'] == 'single') { | |
if (!post_type_exists($settings['post_type'][0])) { | |
return __('The post type: ' . $settings['post_type'] .' doesn\'t existing', WORDPRESS_CONTENT_FILTER_LANG); | |
} | |
$template_loop = $template_loop . '-' . $settings['post_type'][0]; | |
} | |
$columns = apply_filters('wcf_result_columns', $columns, $id, $fields, $settings); | |
$template_loop = apply_filters('wcf_result_loop_template', $template_loop, $id, $fields, $settings); | |
$loop = wcf_get_template($template_loop, false, false); | |
if ($settings['search_type'] == 'single' && $loop == '') { | |
$loop = wcf_get_template('wcf-loop', false, false); | |
$template_loop = 'wcf-loop'; | |
} | |
global $wp_query; | |
$numResults = $wp_query->found_posts; | |
//global $numResults; | |
$GLOBALS['totalResults'] = $numResults; | |
//echo '$totalResults: ' . $GLOBALS['totalResults']; | |
$output .= '<div id="wcf-form-wrapper-' . $id .'" class="wcf-form-wrapper" data-ajax="'.$settings['display_results'].'"' | |
. ' data-form="'.$id.'" data-totalresults="'.$numResults.'" data-loop="'.$template_loop.'" data-columns="'.$columns.'">'; | |
//$output .= '<strong class="results-label">Search (' .$numResults.') Results By:</strong>'; | |
if (is_archive() || is_search()) { | |
// display on archive, search template | |
ob_start(); | |
// | |
if ($loop != '') { | |
include $loop; | |
wcf_pagination(); | |
} | |
$output .= ob_get_clean(); | |
} else { | |
// display posts as archive | |
$paged = ( get_query_var( 'paged' ) ) ? intval( get_query_var( 'paged' ) ) : 1; | |
$args = array( | |
'post_status' => 'publish', | |
'paged' => $paged | |
); | |
$args = wp_parse_args($this->wcf_query->process_vars($id, $_GET), $args); | |
query_posts($args); | |
ob_start(); | |
// | |
if ($loop != '') { | |
include $loop; | |
wcf_pagination(); | |
} | |
$output .= ob_get_clean(); | |
wp_reset_query(); | |
} | |
$output .= '</div>'; | |
echo $output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment