Articles & Insights

Advanced Search

if($_REQUEST[‘submit’]){

$startDate = $_REQUEST[‘selectStartYear’].”-“.$_REQUEST[‘selectStartMonth’].”-“.$_REQUEST[‘selectStartDay’];
$endDate = $_REQUEST[‘selectEndYear’].”-“.$_REQUEST[‘selectEndMonth’].”-“.$_REQUEST[‘selectEndDay’];

$strPublicationType = “”;
if(@$_REQUEST[‘chkPublicationType’]){
foreach($_REQUEST[‘chkPublicationType’] AS $single){
if($strPublicationType == “”){
$strPublicationType = “‘”.$single.”‘”;
}else{
$strPublicationType .= “,'”.$single.”‘”;
}
}
}

//$query = “SELECT * FROM $wpdb->posts, $wpdb->postmeta, $wpdb->terms, $wpdb->term_relationships, $wpdb->term_taxonomy WHERE “.$wpdb->posts.”.ID = “.$wpdb->postmeta.”.post_id”;
$query = “SELECT * FROM $wpdb->posts, $wpdb->postmeta WHERE “.$wpdb->posts.”.ID = “.$wpdb->postmeta.”.post_id”;

if($_REQUEST[‘txtPostTitle’] != “”){
if( substr($_REQUEST[‘txtPostTitle’], 0, 2) == ‘\”‘ && substr($_REQUEST[‘txtPostTitle’], -2, 2) == ‘\”‘ ) {
$keyword = substr($_REQUEST[‘txtPostTitle’], 2);
$keyword = substr($keyword, 0, -2);
$query .= ” AND (“.$wpdb->posts.”.post_title LIKE ‘%”.$keyword.”%’ OR “.$wpdb->posts.”.post_content LIKE ‘%”.$keyword.”%’)”;
} else {
$search_keywords = explode(‘ ‘, $_REQUEST[‘txtPostTitle’]);
$query .= ” AND (“;
$first = 0;
foreach($search_keywords as $keyword){
if($first != 0)
$query .= ” OR “;
$first ++;
//$query .= “(“.$wpdb->posts.”.post_title LIKE ‘%”.$keyword.”%’ OR “.$wpdb->posts.”.post_content LIKE ‘%”.$keyword.”%’ OR (“.$wpdb->posts.”.ID = “.$wpdb->term_relationships.”.object_id AND “.$wpdb->term_relationships.”.term_taxonomy_id = “.$wpdb->term_taxonomy.”.term_taxonomy_id AND “.$wpdb->term_taxonomy.”.term_id = “.$wpdb->terms.”.term_id AND “.$wpdb->terms.”.slug LIKE ‘%”.$keyword.”%’))”;
$query .= “(“.$wpdb->posts.”.post_title LIKE ‘% “.$keyword.”%’ OR “.$wpdb->posts.”.post_content LIKE ‘% “.$keyword.”%’ OR “.$wpdb->posts.”.post_content LIKE ‘%”.$keyword.” %’)”;
}
$query .= “)”;
}
}
if($strPublicationType != “”){
//$query .= ” AND “.$wpdb->postmeta.”.meta_key = ‘publication_type’ AND “.$wpdb->postmeta.”.meta_value IN (“.$strPublicationType.”)”;

$is_cat_filter = true;
} else {
$is_cat_filter = false;
}

if($startDate == “0-0-0″ AND $endDate == “0-0-0″){

}elseif($startDate == “0-0-0″ AND $endDate != “0-0-0″){
$query .= ” AND “.$wpdb->posts.”.post_date <= '".$endDate."'"; }elseif($startDate != "0-0-0" AND $endDate == "0-0-0"){ $query .= " AND ".$wpdb->posts.”.post_date >= ‘”.$startDate.”‘”;
}elseif($startDate != “0-0-0″ AND $endDate != “0-0-0″){
$query .= ” AND (“.$wpdb->posts.”.post_date >= ‘”.$startDate.”‘ AND “.$wpdb->posts.”.post_date <= '".$endDate."')"; } $query .= " AND ".$wpdb->posts.”.post_status = ‘publish’ AND (“.$wpdb->posts.”.post_type = ‘post’ OR “.$wpdb->posts.”.post_type = ‘pdf’) GROUP BY “.$wpdb->posts.”.ID ORDER BY “.$wpdb->posts.”.post_date DESC”;
//echo $query;
//exit;
$searchPosts = $wpdb->get_results($query, OBJECT);

/* PAGINATION */
$totalposts = $wpdb->get_results($query, OBJECT);
$ppp = intval(get_query_var(‘posts_per_page’));
$wp_query->found_posts = count($totalposts);
$wp_query->max_num_pages = ceil($wp_query->found_posts / $ppp);
$on_page = intval(get_query_var(‘paged’));
if($on_page == 0){
$on_page = 1;
}
$offset = ($on_page – 1) * $ppp;
$wp_query->request = $query . ” LIMIT $ppp OFFSET $offset”;
$pagePosts = $wpdb->get_results( $wp_query->request, OBJECT );
/* PAGINATION */

if($pagePosts){
global $post;
$num = 0;
foreach($pagePosts as $post){
setup_postdata($post);

$attachment_id = 0;
if(get_post_type($post->ID) == ‘pdf’) {
$attachment_id = $post->post_parent;
$attachment = get_post($attachment_id);
$parent = get_post($attachment->post_parent);
$category = get_the_category($parent->ID);
}
?>
ID == ‘pdf’)) {
$publication_type = get_post_meta($parent->ID, ‘publication_type’, true);
} else {
$publication_type = get_field(‘publication_type’);
}
if(in_array($publication_type, $_REQUEST[‘chkPublicationType’]))
$show = true;
else
$show = false;
} else {
$show = true;
}
// Ignore non-associated pdfs
if( get_post_type($parent->post_parent == 0) ) {
$show = false;
}

?>


ID) == ‘pdf’) {

if(get_post_meta($parent->ID, ‘publication’, true) != “” ) {
$publication = get_post_meta($parent->ID, ‘publication’, true);
echo $publication.”  |  ” . get_the_time(“d F Y”, $parent->ID);
}

} else {
if(get_field(“publication”) != “”){
echo get_field(“publication”).”  |  ” . get_the_time(“d F Y”, $post->ID);
}
}

//echo get_the_date(‘d F Y’);
?>

ID) == ‘pdf’) : ?>
ID, ‘custom_url’, true);?>” rel=”bookmark” title=”Permanent Link to ” target=”_blank”>

-->

ID) != ‘pdf’ ) the_content(‘Read the rest of this entry �’); ?>
-->

Not Found

Sorry, no results found. Please adjust your search criteria and try again.


Not Found

Sorry, no results found. Please adjust your search criteria and try again.