Note that there are some explanatory texts on larger screens.

plurals
  1. POwordpress query trouble
    text
    copied!<h2>EDIT:</h2> <p>heres my file thats running the query maby its something else acting up - <a href="http://pastebin.com/4Cw3xMEM" rel="nofollow noreferrer">http://pastebin.com/4Cw3xMEM</a></p> <hr> <p>this works as a direct query in SQLyog</p> <pre><code>SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post' AND YEAR(post_date)=2010 ORDER BY post_date DESC; </code></pre> <p>it returns the three posts which are from 2010 but when i try run it via my wordpress it pumps out all the posts, regardless of date</p> <p>i know theres a few things to be done so it selects the correct tables and as far as i can gather, the following 'should' be alright</p> <pre><code>SELECT wposts.* FROM $wpdb-&gt;posts wposts, $wpdb-&gt;postmeta wpostmeta WHERE wposts.post_status = 'publish' AND wposts.post_type = 'post' AND YEAR(wposts.post_date)=2010 ORDER BY wposts.post_date DESC; </code></pre> <p>i really dont understand the ' wposts. ' at all, but it uses this sort of thing in the examples on wordpress codex</p> <p>the ultimate goal is to make a query to pull posts froma certain year, and use that to make WP display groups of posts per year</p> <p>i cant find anything that helps explain how to properly call the querys using the wordpress structure</p> <p>if someone can explain a few of these things it might help alot, example, with the following:</p> <pre><code>$wpdb-&gt;posts </code></pre> <p>i have no idea what '->' is for, i have only seen it used in php for assigning parts of an array in a foreach</p> <ul> <li>how do i get this thing to work?</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload