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 need price sorting, where price is a metakey that is serialisez with other metakeys and stored in wp_postmeta

I need something like this:

When user click on free (Anchor tag) it should show posts with price '0'

When they click on paid (Anchor tag) it should show posts with price excluding '0'

Serialised Meta value a:7:{s:19:"et_is_editor_choice";s:1:"0";s:15:"et_fs_variation";s:1:"0";s:12:"et_fs_button";s:0:"";s:10:"et_fs_link";s:0:"";s:11:"et_fs_price";s:0:"";s:17:"et_affiliate_link";s:0:"";s:17:"et_affiliate_text";s:0:"";}

share|improve this question
    
you will find it prohibitively difficult to query on PHP serialized data, as it is essentially nonsense as far as MySQL is concerned. you should store price separately under its own key if you want to query on that data. –  Milo May 4 '12 at 15:35
    
@Milo - can you post this as an answer? - it is after all, the correct one :) –  Stephen Harris May 4 '12 at 18:27

1 Answer 1

You will find it prohibitively difficult to query on PHP serialized data, as it is essentially nonsense as far as MySQL is concerned. You should store price separately under its own key if you want to query on that data.

share|improve this answer
    
I thought about that but, i have more than 5000 posts. Is there any other way. –  dayakar reddy May 7 '12 at 12:05
    
@dayakarreddy - the only way I know of is to select every post, unserialize every meta value, then compare them all with php, which is obviously not a realistic solution. –  Milo May 7 '12 at 13:43

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.