These forums are closed.
Please post issues at the wordpress plugin site.
Query Wrangler support forums
Widget Wrangler support forums

Intro to Query Wrangler

Forrest Livengood's picture

If you're familiar with Drupal Views then you'll be right at home with Query Wrangler. If you've never used Drupal's views you'll be pleasantly surprised with how easy it is to build a powerful query and display it as a widget or a page.

Adding a Query

Query name

Give the query a name. This name is only displayed to the admin, not the user.

Query Type

  • Widget Query: Create a query that will be available as a widget to place in the sidebar.
  • Page Query: Create a query that becomes it's own page. This query required you to give it a page path where the query can be seen. For example you want to list all of the users that are Editors on your site. Create a Page Query and set the page path to team/members. Then when users go to [yoursite.com]/team/members they will see the query.
  • Override Query: Create a Query that takes the place of an existing WordPress page such as the Catagory or Tag pages display.

Basic Settings

Title

This is the title that will be displayed to the user with your query

Style

  • Full Posts means that all of the fields associated with a post or a page will be displayed in the query. Fields means that you can decide to only show certain fields from the post in the query. This would be useful if you only wanted to show the titles of posts, or maybe titles and dates but not the teaser.
  • Full Settings: If you've selected Full as the style you can set the Full Settings to either Complete or Excerpt. This means that the body of the post will either show completely or only an excerpt will be displayed in the query.
  • Field Settings: If you've selected Field as the style you can set the Field Settings to unformatted, unordered list or ordered list. This governs how each query entry will be displayed. For instance if you select unformatted each row of the query will be displayed in a <div> element. If you select unordered each row will be displayed as a bulleted item in an unordered HTML list. Selecting ordered list will display the rows as a numbered item in an ordered HTML list.

Items per page

Items per page allows you to set how many items should be displayed on each page or widget.

Offset

Offset allows you to skip a certain number of items at the beginning of the query. For example if you have a list of posts: post 1, post 2 and post 3 with no offset they would be displayed normally. But if you change the offset to 1 the display will be post 2 and post 3. Changing the offset to 2 would only display post 3.

This is useful if you have two widgets close together, one is for featured items and the other is for the rest of the items. You can use the same query parameters but set the Items per page on the Featured widget to 1. Then on the second widget set the items per page to however many other items you want to show and set the offset to 1. This way the featured item in the first widget will be skipped.

Sort Options

Order by
The order by option allows you to select how you'd like to order your query items. The options are:

  • None: No sorting is used
  • Post ID: Items are sorted by their post ID
  • Author: Items are sorted alphabetically by their Author
  • Title: Items are sorted alphabetically by their Title
  • Date: Items are sorted chronologically by their post date
  • Modified: Items are sorted chronologically by their last modified date
  • Parent: Items are sorted alphabetically by their Parent
  • Random: Items are sorted randomly
  • Comment Count: Items are sorted by their comment count. This is a good way to sort for popularity
  • Menu Order: Items are sorted by their menu order. This only applies to Page types

Order

You can select whether to display the items in ascending or descending order. Ascending order is forwards like an alphabetical sort, descending order is backwards like dates from the future to the present.

Header

This is a place to put content or markup to appear above the query. This only appears once over the whole query, not above each row within the query.

Footer

This is a place to put content or markup to appear below the query. This only appears once below the whole query, not above each row within the query.

Empty Text

This is the text displayed if the query returns no results. This is useful for dates "No upcoming events found" or for other purposes "There are no users who are Editors"

CSS Classes

Here you can add a custom CSS class that will be placed on the query so you can style it any way you'd like.

Filters

Filters allow you to only include the content you want in your query and filter out everything you don't want.

Post Types

You can select which post type you want to include in your query

Post Status

  • Published: only allow published content in the query. This would be good for a list of posts with the highest number of comments.
  • Pending: only allow pending content in the query. You could use this for an admin widget showing an Editor how many posts are pending review.
  • Draft: only allow draft content in the query. Filtering by Draft could be used to show a user how many posts they have saved as draft.
  • Future (Scheduled): only allow content that is scheduled for the future. Tease users with the titles of upcoming articles to keep interest high.
  • Trashed: only allow content that has been trashed. Make a widget for admins to keep an eye on content being thrown out around the site.

Catagories

Filter content by the catagory it's in. Multiple catagories can be selected at once.

Catagory Options:

  • Any catagory plus children catagories: Include catagories that are children of the selected catagories.
  • Any catagory without children catagories: Use content from any catagory that does not have any child catagories.
  • All Catagories selected: include content from all selected catagories.
  • Not in the catagories selected: This is a negative selection. If you have the catagories Baseball, Basketball, Football and Hockey and check Hockey and Football normally that would include content only from Hockey and Football. But if you select Not in the catagories selected with Hockey and Football checked the query will pull content from all catagories but those two.

Tags

Filter content by tags. Multiple tags can be selected at once.

Tag Options

  • Any of the selected tags: If multiple tags are selected and content has any one of those tags it will be included
  • All of the selected tags: If multiple tags are selected content will not be included unless it has all the tags selected.
  • None of the selected tags: If multiple tags are selected content will be included as log as it doesn't have any of the selected tags.

Page Parent

Page content will only be included if it's parent is the same at the one listed in this field

Fields

If you selected Fields in the Style option under Basic Settings you'll get a new set of options allowing you to add specific fields.

Add Fields

You will be shown all of the available fields associated with the Post Types you've selected in the Filters section. You can select as many as you'd like. Once you've selected the fields click Add Selected Fields.

You can then click on each field to fine-tune its display:

  • Exclude this field from display: This will include the data in the query but not display it. This is useful if other fields use this one for calculations
  • Link this field to the post: Clicking this will make the field link to it's post page. This is very useful for Title fields and fields used for custom "read more..." links.
  • Create Lable for this field: Create a label to display with the field. This is useful if you have a field that's a plain number with no explaination.
  • Rewrite the output of this field: If you'd like to customize how the field is output click this. It gives you access to tokens representing all of the fields that are selected before it. Using this and the Exclude this field from display you can make a field display complex inline values.

Rearrange Fields

Rearrange the order that the fields are displayed. This is also helpful when you are hiding the output of some fields and rewriting their contents with others. Make sure the field that is rewriting the others is arranged after the hidden fields so it has access to their values as tokens.

Replies

Awesome!

First off - thank you very much for creating this plugin! Been involved in a few Drupal projects and find Views to be an invaluable tool - so to see that same type of efficiency brought to WordPress is amazing. I did have a few questions:

1. Any chance those filters can be expanded to include custom meta data? For example, filter content that has a certain meta value?

2. Could those filters be exposed to front-end users so that they could filter down by specific content? For example, an alumni list that gave users the ability to filter down by a specific teacher based on the year they graduated.

3. ^ Same question for sorting (by things like post name, meta fields, etc)

4. ^^ AJAX filtering by the two aforementioned items.

5. Any chance taxonomy and users lists will be added-in there? Basically thinking about this as an area to list categories and have users be able to filter down to a category that ultimately holds content and for users, well... a user list :)

3. I tried adding in a value in "page path" and it didn't seem to do much. Bear in mind the install is in a sub-directory - do you think that could be the issue? I basically created a page with the same slug I specified - and then ultimately had to put in the shortcode.

I don't know how I didn't find this earlier - but is honestly amazing and can't wait to see what's in store! And just as I write this, I decided to check-out the other plugins... speechless. Thank you again!

daggerhart's picture

Hi Zach, 1. I've taken a

Hi Zach,

1. I've taken a crack at filtering by meta data and it didn't turn out well. I'll give it another go since I know someone wants it.

2 & 3. We're working on exposing filters, so exposing the sort shouldn't be much of a problem.

4. I enjoy working with ajax, so sure, I'll add this to the todo-features list

5. Users seems like an obvious addition. I would need to think more on taxonomies, and what would be expected of them.

6 (3). I suspect that is related to it being in a sub directory. I'll test it out and try to fix it.

Really appreciate the reply.

Really appreciate the reply. With 1.4.1BETA - I saw the Filter API was introduced, but not actually implemented for users to take advantage of as of yet, correct? Thanks!

daggerhart's picture

Hi Zach, The filter api I

Hi Zach,

The filter api I mention in the update notes is more for allowing other plugins to provide their own filters. I don't think it's 100% ready yet, because it needs more testing. This doesn't allow for exposing filters the way you had requested yet, but will make that easier in the future.

The main reason for release 1.4 now was to fix some bugs other users were dealing with concerning tag pagination.

In continuing to add to the filter api to make it very flexible for other plugins to contribute, as well as incorporating exposed filters.

I will go ahead and vow now to have exposed filters with the 1.5 release. The biggest roadblock for this is that wordpress has nothing like drupal's form API, so a replacement methodology will need to be figured out.

Concerning the page-path within a sub-directory. Have you tried making the page's path include your sub-directory? So, if you have wordpress installed in the blog/ directory, make the query;s page path '/blog/page-path' ?

Also, adding the shortcode to an actual page is a good solution if you continue having problems. I approached query pages as a custom post type, but didn't like the results.

Hi daggerhart, Thanks for the

Hi daggerhart,
Thanks for the explanation. Not sure if you had seen http://wordpress.org/extend/plugins/custom-query-fields/ but it seemed to be an interesting solution for querying meta/custom fields (which could come in handy here). Adding the shortcode to the page should work fine for me for now like you mentioned - I might look into how that path is constructed (almost as if it's just a `bloginfo()` tweak - as far as how it's being referenced). Thanks!

Hi daggerhart, In addition to

Hi daggerhart,
In addition to my last comment, http://wp.tutsplus.com/tutorials/create-a-product-listing-with-infinite-... is what I was thinking of for the taxonomy drill-downs. Thanks!

Hi daggerhart, Need any

Hi daggerhart,
Need any testers for any exposed filters/sorting options? Thanks!

Also - to further comment on

Also - to further comment on the taxonomy example I mentioned before (being able to have an infinite category drill-down), http://www.ringsend.com/products/moulding-millwork/in-stock-profiles is an example (in Joomla) that we'd love to be able to duplicate in WordPress. Thanks!

daggerhart's picture

I still don't have exposed

I still don't have exposed filters and sorts implemented yet, but I will definitely need a tester as soon as I start tackling it. Thanks for the support, I'll be in contact about that.

Thanks for the 2nd example of the taxonomy drilldown, that's very helpful. I didn't get a chance to fully comprehend that first example, because it required a lot of programming just to get it setup.

Tags / Categories

Wondering, I know that we can 'filter' by tags / categories, but what about displaying in the 'results' all the categories / tags that are associated with each post? Is this possible?

If so, how?

Category filters not working correctly

Hi Guys,
I've installed Query Wrangler, and have created a query that assumes that a single category and a combination of one or two tags are present. Based on the configuration screen for this query, I expected to only see items appear which have this category selected, but I find that other posts are also included in the query.
When I run the query, it presents the first of 2 posts that completely fit my filter profile. The first post has both forward and backward buttons. Pressing the forward button gets me to the 2nd post, as it should, but pressing the back button gets me to other posts, which do not meet the filter criteria. Am I doing something wrong?
Thanks
Cliff
PS, this site is not live yet, and as a result, cannot be viewed outside of the Oracle firewall, so I'm afraid that I cannot grant you access to the site at this time.

order by custom field

Nice plugin!
- what about sorting the query results by custom Meta-value ?

Hi, coming from Drupal, I

Hi, coming from Drupal, I very much appreciate the Views-like interface of the module. Thanks.

I may be extraordinarily dim, but I can't see how to Rewrite the field output. When I check the option, all that happens is that the field disappears from view. There's nowhere that I can enter any code or set any options. What am I missing?

daggerhart's picture

Hi Techczech, The field

Hi Techczech,

The field *should* appear when you check the box, but a friend of mine who uses a mac experienced a lot of problems.

If the field doesn't appear when you check the box, try using a different browser. If that doesn't help you can use firebug or something to make the field display.

I've been having health issues recently and haven't had time to give this as much attention as it deserves. If you can, you should find the css or js that is hiding the textarea and just remove it from the QW code.

Sorry this isn't very helpful. I hope to get back to this project in a few weeks.

Jonathan

daggerhart's picture

Techczech, query-wrangler-vie

Techczech,

query-wrangler-views.css line 124. Remove .qw-field-options-hidden and the comma at the end of the line above it (123).

That should make all the hidden fields show up.

Thanks Jonathan. I was

Thanks Jonathan. I was working on Win 7 with the latest version of Chrome and Firefox and it wasn't displaying in either. But when I modified the CSS file, all was resolved. I would suggest making that the default interface.

On an unrelated note, while I was doing this, my server crashed (due to APC misconfiguration) and the Query I was working on was replaced with empty values. It didn't take me long to fix it, so it wasn't a big deal but I thought you might want to know. But it's possible that there's nothing that can be done.

Dominik