google-code-export / wordpress-custom-content-type-manager

Automatically exported from code.google.com/p/wordpress-custom-content-type-manager
2 stars 1 forks source link

saving meta as string or number not array #568

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem? (Be *specific*)

Regular Wp_Query 
looks like this:
$args = array(
    'post_type' => 'post',
    'posts_per_page' => '9',
    'meta_key'   => 'bike_sold',
    'orderby'    => 'meta_value',
    'order'      => 'DESC'
);
// The Query
$the_query = new WP_Query( $args );
....

What is the expected output?

the expected output is loop sorted by meta value, but that works only when the 
meta value is a number or string, not array. All meta values made by CCTM are 
stored in some kind of array.
How can I convince the CCTM not to save meta as array but plain text, or 
number, so that the wp_query can sort it as usual?

Now I get 
array(1) { [0]=> string(4) "1500" } 

And I want the meta to be saved as::
string(4) "1500" 

Original issue reported on code.google.com by 2...@emblem.cc on 20 Aug 2014 at 1:57

GoogleCodeExporter commented 9 years ago
I'm sorry, forget it.. I'm dumb ;/

Original comment by 2...@emblem.cc on 20 Aug 2014 at 2:24

GoogleCodeExporter commented 9 years ago
That's the way it's built: meta data is stored as JSON arrays when the fields 
are "repeatable" (i.e. contain multiple values).  This has benefits and 
drawbacks.  See 
https://code.google.com/p/wordpress-custom-content-type-manager/wiki/CustomField
sDataStructure for the technical discussion.

The getPostsQuery class (included in the CCTM) offers what I felt was a more 
flexible API for searching on the posts and postmeta tables (see 
https://code.google.com/p/wordpress-custom-content-type-manager/wiki/GetPostsQue
ry). 

Original comment by ever...@fireproofsocks.com on 20 Aug 2014 at 4:16