With some trial and error and help from @vancoder , the problem had to do with intval
.
The only section needing to be modified was the posts_where
function.
Had to remove the following line:
$propertytype_value_number = intval( $_GET['propertytype_value_restrict_articles'] );
And change:
AND meta_value=$beds_value_number )";
to
AND meta_value="".$_GET["propertytype_value_restrict_articles']."' )";
I had to also modify the original function and remove the && intval( ) !=0
argument in order for it to work.
Here is the revised working code for filtering meta_value from a custom string.
function.php
function posts_where( $where ) {
if( is_admin() ) {
global $wpdb;
if ( isset( $_GET['propertytype_value_restrict_articles'] ) && !empty( $_GET['propertytype_value_restrict_articles'] )) {
$where .= " AND ID IN (SELECT post_id FROM " . $wpdb->postmeta ."
WHERE meta_key='propertytype_value' AND meta_value="".$_GET["propertytype_value_restrict_articles']."' )";
}
}
return $where;
}
add_filter( 'posts_where' , 'posts_where' );