Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I´ve read almost this articles but unfortunately my query is no working, I think i´m very close but could be so far away.

I´m trying to get metadata using a custom form with method get,

$rob = $_GET['rob'];
$bedrooms = $_GET['beds'];
$bathrooms = $_GET['baths'];

the array is $args = array( 'meta_query' => array( array( 'key' => 'beds_value', 'value' => '$bedrooms', 'compare' => 'LIKE',

        ),
        array(
        'key' => 'baths_value',
        'value' => '$bathrooms',
        'compare' => 'LIKE',

        ),
        array(
        'key' => 'rob_value',
        'value' => '$rob',
        'compare' => 'LIKE',

        ),          
),
);

$args = array_merge( $args , $wp_query->query );
query_posts( $args );

depending on final query the results are diferent

this display none, seems to be this clean the query
$args = array_merge( $args , $wp_query->query ); query_posts( $args );

but if is used $query = new WP_Query( $args ); I get all results without any filter. but I can see the query data Ex 2 beds, 2 baths

Do I need to write something more?

share|improve this question
add comment

1 Answer

I believe the problem is that you are using single quotes in passing values to query (e.g. 'value' => '$bedrooms'), but this way the variables are not expanded (see http://php.net/manual/en/language.types.string.php). Simply use 'value' => $bedrooms.

share|improve this answer
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.4.18.1558\r\n            </div>\r\n                <div id=\"additional-notices\">\r\n                    WordPress is a trademark of the WordPress Foundation, registered in the US and other countries. This site is not affiliated with the WordPress Foundation in any way.\r\n         "], "copyright__copyright__copyright": ["nswer\n\nI believe the problem is that you are using single quotes in passing values to query (e.g. 'value' => '$bedrooms'), but this way the variables are not expanded (see http://php.net/manual/en/language.types.string.php). Simply use 'value' => $bedrooms.\n\nshare|improve this answer\nshow 4 more comments\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}