How to replicate some of Drupal Views functionality in WordPress?

  1. display custom fields in columns and rows: get_post_meta to display them in your theme, and add_meta_box to customize the admin

  2. Expose filters, that is, create drop-downs at the top, to allow the end user to select:
    you may want to use the custom fields parameters of query_posts. E.g.:

Dropdown field in a form at the top:

<select name="custom_field" id="custom_field">
    <option value="value1">Value 1</option>
    <option value="value2">Value 2</option>
</select>

Corresponding custom query:

$value = $_POST['custom_field'];
query_posts("meta_key=custom_field&meta_value=$value");

You may want to see The Loop and get_posts for reference.

Hope this helps.

Leave a Comment