We’re ready with Views 0.9.4. This release adds some great new features and opens completely new horizons for what you can build with Views.
Until now, a View could query only the ‘posts’ table. This includes posts, pages and any custom post types. But, what about Taxonomy?
For example, supposing you’re keen on making a classified site, just like our new sample classified.
The site revolves around categories. First, we display different product categories and then you can drill-down and see what they include.
The new Taxonomy Views does just that. Instead of querying the Posts table, it queries the taxonomy table.
But wait, there’s more!
Often times, you’ll also want to list posts that belong to each taxonomy. Let’s look at our sample magazine site:
You’ll notice that we’re listing two categories (technology and sport). Each of them lists several posts that belong to that category.
To build that, we use nested Views. The outer View loads and displays categories. The inner (posts) View displays the posts that belong to that category. When you edit a Post View, look at the ‘taxonomy filter’. You’ll see a new option to choose the taxonomy set by the parent View.
You may need to craft output HTML, as a function of post content. For example, look at this list of todos:
Notice how a completed todo item is striked out? To build this, we need to wrap the title of completed todos with <del> and </del>. Of course, these del tags are added when we display the data and not into the database.
Views 0.9.4 has a new expressions-evaluation engine. This can include simple stuff like checking if a field or set and can go up to complex expressions that include logic conditions and combinations of any number of fields.
It’s documented in the conditional HTML output page.
This allows you to add ‘if’ logic to your Views and View Templates. It gives all the power you’d have when coding in PHP, just without the actual coding.
Shortcodes within Shortcodes
Talk about something super technical…
Let’s say that you have a shortcode for an iPhone app (I personally use an Android device, but don’t worry about me).
Your shortcodes look like:
Where that 12345 is the ID of a certain app. Now, you’re asking a pretty legitimate question:
“How do I control the ID of the application with a custom field?”
Unlike previous Views versions, Views 0.9.4 makes it look trivial. Just write:
[app [types field="itunes-id"] ]
See? That wasn’t so bad. Now that you can use Types shortcodes inside of other shortcodes, you can user Types and Views to control your own shortcodes using custom fields. This includes all the standard codes (like Gallery) and your own ones.
It’s great when things just work, but what to do when they don’t? For example, you created a lovely View and it’s returning nothing. Where do you start checking?
Since this happens to me on a regular basis and I don’t really enjoy firing up a PHP debugger, we added our own simple-debugger to Views.
Now, you can get a complete log of what Views does. It’s all documented in the debugging Types and Views page.
The debugger uses the browser’s console. If tells you which Views and View Templates are loading, what they’re getting from the database and what they’re doing with it.
With this, you can immediately trace and understand what Views does and save on all that time spent on wondering and experimenting.
The debug output goes to the console, so you can enable it safely without compromising the HTML output.
Other New Features
Just a few other things and we’re done:
- Added a way to order View results randomly
- Add format parameters to the wpv-post-author shorcode
- Add 2 additional options to the taxonomy filter for selecting taxonomy based on attribute passed to a View or passed by a URL parameter
- Add “Edit View Template” an shortcode “wpv-post-edit-link”
And, we’ve also fixed a number of bugs:
- Fixed AJAX pagination for a widget View
- Use the View Template title instead of the View Template ID in select boxes
- Stopped hidden custom fields from displaying in the V icons or when adding fields to View layout
- Using title instead of slugs in the table headings
- Improved output of the excerpt shortcode
- Stopped including the current post in the posts returned by a query
- Fixed a bug that happened when there is more than one view on a page
Upgrading to Views 0.9.4
You should see this new version in your Plugins admin page in WordPress (WordPress has a 12 hours cache on new plugin versions). To upgrade automatically, be sure you’ve entered your subscription email and key.
You can also upgrade by downloading Views 0.9.4 from your account.
What do You Think?
We’d love to hear your feedback and see what you’re building with Views.
You’re invited to leave your comments here. If you want your site added to our showcase, head over there and fill the add-new-site form at the bottom.