Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge pull request #2 from szk11001/master
Browse files Browse the repository at this point in the history
Modify News Archive search
  • Loading branch information
jmr06005 committed Feb 18, 2015
2 parents 0c731b0 + b38b822 commit e689b06
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,15 @@ function prefix_ajax_clas_cat_posts() { //Retieves posts of a specific category
die();
}


add_action( 'wp_ajax_clas_search_archive', 'prefix_ajax_clas_search_archive' );
add_action('wp_ajax_nopriv_clas_search_archive', 'prefix_ajax_clas_search_archive');
function prefix_ajax_clas_search_archive() { //Retieves posts of a specific category or tag, using cat/tag id
$search = $_POST['search'];

global $wpdb;
$results = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_title LIKE %s;", '%' . $wpdb->esc_like($search) . '%') );
$archiveQuery = new WP_Query( 'category_name=archive&fields=ids' );

$archiveQuery = new WP_Query( 'category_name=archive&fields=ids&s='.$search.'' );
$archivePosts = $archiveQuery->get_posts();
$object = new stdClass();
foreach( $results as $k=>$id ){
foreach( $archivePosts as $k=>$id ){
if( in_array($id, $archivePosts) ){
$link = get_permalink($id);
$title = get_the_title($id);
Expand Down

0 comments on commit e689b06

Please sign in to comment.