0

I'm having an issue with the conditional value query issue. I want to query 2 posts, if the value at Minimum Price, is less then 30 euro. Then query 2 posts. It's a affiliate website, with around 1200 posts with different content.

My code is at: http://pastebin.com/SDpcKspu

The problem is, that mostly my website is showing values <30. But sometimes it happends that i see a value that is way larger (around 130 euro or so). Any idea?

And yes, I know that this bit at orderby is double, but this seems somekind to work.: <?php query_posts('cat=77,98'.'&orderby=meta_value&orderby=rand&meta_key

Website is at http://www.overhemd-heren.nl regarding the widgets at the right side.

I picked the 30 euro example, but the same is for 50 and 40 euro.

Who can help me?

1 Answers1

0

Have you really named a meta key 'Minimum Price' with a space between it? Are you sure the key is named this in the database? Also with the same case(hoofdletters)? try this:

<?php
query_posts( array(
'cat'=> '77,98',
'meta_key'=> 'Minimum Price',
'meta_value' => '30.00',
'meta_compare' => '<',
'order' => 'desc',
'orderby' => 'meta_value_num',
'posts_per_page' =>'2' //showpost is deprecated and should not be used anymore.
));

Probably won't fix it but it's easier to read.
http://codex.wordpress.org/Class_Reference/WP_Query

edits, 1 orderby; meta_value is now between quotes

janw
  • 6,672
  • 6
  • 26
  • 45
  • Thnx for your reply. But how is the query going to look? I'm still a bit new with wordpress. I tried this, but that doesn't work. http://pastebin.com/f1VcMiBf can you give me a example how my code is going to look like? Thnx! – Thomas van der Bijl May 17 '12 at 13:15
  • See my edit above, your pastebin has an error `echo "a href="";` will give you a lot of errors. You are opening php within php – janw May 17 '12 at 14:15
  • Here a pastebin for you wrong `echo` http://pastebin.com/4uvdrJwZ I can see you are very, very new because you make 7 mistakes in 1 line. there are other smaller errors in your script. My fix wont help with those. – janw May 17 '12 at 14:25
  • Janw, bedankt! I'm getting to know the basics now, i'm more a HTML/CSS guy. Would love to know more about php/WP. I've a question now. My code ATM is: http://pastebin.com/JVkDXjbJ The problem is, that the code you send me, doesn't fetch the Value of the field 'Link'. It gives a empty field back. Any idea why this happend? I tried to get the values back from 'Brand', 'Image', Old Price', 'Minimum Price' but they all didn't displayed the info. Look for www.overhemd-heren.nl at the block at 30 euro. Thnx so much for your help! – Thomas van der Bijl May 17 '12 at 17:09
  • yes I know the problem there are still multiple, and it's growing out of this question. Please upvote and accept my answer. And add me to skype: *myusername*.oostendorp We're both Dutch so meeting shouldn't be that hard. I'm online pretty much all day (today). – janw May 18 '12 at 07:54