Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5530

Markgasm on "wp_posts custom mysql column name"

$
0
0

I've just realised that it overwrites the entire search query aswell

so my search items become balnk but my filters are recognised

global $query_string;

$query_args = explode("&", $query_string);
$search_query = array();

foreach($query_args as $key => $string) {
	$query_split = explode("=", $string);
	$search_query[$query_split[0]] = urldecode($query_split[1]);
} // foreach

//applying filters somewhere here the search query becomes lost

$search = new WP_Query();
add_filter('posts_where', 'filter_where');
$search->query($search_query);

// loop

if ($search->have_posts()) {
	while ($search->have_posts()) {$search->the_post(); ?>
<?php include('/include/post_list.php') ?>
<?php } }
wp_reset_postdata();
?>

and in my funtions.php

function filter_where(){

   $where .= "AND (wp_posts.post_region = '4')";
	return $where;

}

Viewing all articles
Browse latest Browse all 5530

Trending Articles