0

I have a template that seems to only accept variables given though query_posts(), which appears to work like get_posts(), but it's too restricting. So I need to either do it somehow without query_posts() or find a way to include filters like

posts that have one or more of several values in this meta value of this meta key with authors who have this value in their meta key

inside of it. So far I've been unsuccessfull with both.

Is there anything that would help me?

  • You say that the template does not accept anything but query_posts, which seems like a major bug to me. Can you elaborate a little more on this? I mean, what other than query_posts have you tried, and why did it not work? – simonthesorcerer Aug 4 '15 at 19:31
  • You can modify the result of query_posts() using filters provided by WordPress. take a look here: codex.wordpress.org/Custom_Queries – WisdmLabs Aug 5 '15 at 5:25
0

It's not clear what do you mean by template "accepting" variables.

WP_Query (which query_posts()/get_posts() are build on top of) is very flexible. In many cases it's not as much being able to do something with it, as having experience using it to achieve results.

Typically even when queries cannot be expressed in single set of arguments, it is still very possible to make "compound" queries, by querying partial post sets and further using them in additional queries.

That said it is quite possible to use raw SQL. As long as you retrieve records from posts table accurately, you can instance WP_Post objects from them. Note that this will skip much of related WP functionality, such as caching, etc.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.