Show HN: The WordPress Query Generator, create WP loops in plain English
wpquerygenerator.com
wpquerygenerator.com
I would heartily agree that the documentation [1] isn't great, but it's generally very easy to use and quite powerful.
Seriously, you're apologizing for this? This is just one of the myriad examples of what a mess Wordpress is, and it's at core of the functionality.
Here's a random example from that docs page:
$args = array(
'post_type' => 'my_custom_post_type',
'meta_key' => 'age',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'age',
'value' => array(3, 4),
'compare' => 'IN',
)
)
);
$query = new WP_Query($args);
So it's returning posts that:- Are of the post type: "my_custom_post_type",
- That contain a custom field with the key of "age",
- That are in ascending order by the value of the aforementioned custom field,
- Where the "age" field is equal to either 3 or 4.
That seems relatively easy and straightforward to me.
The bit that you brought up is the loop, which is the canonical way of displaying the posts retrieved by a query. You don't have to, of course, you can just get an array of them and foreach your way through. The abstraction does allow for quick, easy, and relatively flexible development. I'd fully believe that it's messy on the backend, but that honestly doesn't normally affect my day-to-day usage.
Now, I'm not about to argue the merits of the core architecture of Wordpress - that's beyond my expertise. But I use it daily for client work, and it works very well for my needs.
WP isn't a framework. It's a CMS. A shitty one that needs to go away, but criticizing it for not having the same feature-set as modern frameworks is simply unfair and unnecessary.
Saying WP is a shitty CMS is easy, but where is a good alternative? There is none.
Anyone can say anything about WordPress, but the FACT is that it's most used CMS, with a BIG community and market arround it.
People saying it's shitty don't know what they are talking about (even you point out others you've tried are worse).
Wordpress is best in class for what it is: open source content manager. It's best use case is for a simple blog. It can be bashed into submission to be an ok general CMS or even a community managment solution. Past that though, it's architecture falls to pieces - but then, you wouldn't use a hammer to drill a hole would you?
Too far into that extreme gets into Drupal-land.
I have `WP Query` as a snippet on my IDE because it's faster than typing, this is essentially the same as a web interface , it makes no sense to bash what is essentially auto-complete. WordPress comes with many default parameters because it's convenient, if you don't want to use them, create your own, there's nothing stopping you from doing that.
tl;dr The last time I checked a `while loop` was a basic control statement of most every programming language.
This would be really strong if it allowed you to generate more complex queries. For instance, you can't select more than one post status, select a custom post type, or use meta fields as part of the query.
I get that it's meant to provide a nice starting point, but value for me (and I get that I might not be a target) would be a natural language abstraction of the more complex queries.
http://wp-types.com/home/views-create-elegant-displays-for-y...
Other than that, this looks like a very nice site for a non-programmer or new programmer who wants to customize a theme they found.
Here's a good WP Query resource I've been using to structure marginally complex queries:
https://gist.github.com/luetkemj/2023628It has a more conventional builder-style API that may answer the complaints of those wishing for a more straightforward way to write loops.