[wp-trac] [WordPress Trac] #15340: meta_value needs needs more flexibility to be either a string or an integer

WordPress Trac wp-trac at lists.automattic.com
Tue Nov 9 10:31:31 UTC 2010


#15340: meta_value needs needs more flexibility to be either a string or an integer
--------------------------------------+-------------------------------------
 Reporter:  jcskyrocket               |        Owner:           
     Type:  defect (bug)              |       Status:  closed   
 Priority:  normal                    |    Milestone:           
Component:  General                   |      Version:  3.0.1    
 Severity:  normal                    |   Resolution:  duplicate
 Keywords:  meta_compare, meta_value  |  
--------------------------------------+-------------------------------------

Comment(by jcskyrocket):

 Replying to [comment:2 nacin]:
 > Note, in 3.0-, you could have used meta_value_num. What's in trunk is
 just more powerful and intuitive.

 What is the correct way to use meta_value_num to force meta_compare to use
 integers? I was only able to use meta_value_num as a value for orderby.

 Here is my code:

 {{{
 query_posts(
         array_merge(
                 $wp_query->query,
                 array(
                         'category__and' => $mycatids,
                         'meta_key' => 'price',
                         'orderby' => 'meta_value_num',
                         'meta_compare' => '<=',
                         'meta_value' => $mymetavalue,
                         'order' => 'DESC'
                 )
         )
 );
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15340#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list