A simple example for adding a custom Field to Query Wrangler as its own plugin. You can save this as a file in your wp-content/plugins/
folder, activate the plugin, and use this field in your queries.
<?php
/*
Plugin Name: Custom QW Field Example
Description: Example of custom Query Wrangler field with $post and $field parameters.
Author: Jonathan Daggerhart
Version: 1.0
*/
add_filter('qw_fields', 'custom_qw_field');
function custom_qw_field($fields)
{
$fields['custom_qw_field'] = array(
'title' => 'Custom QW Field',
'description' => 'Just an example of making your own custom fields with callbacks.',
'output_callback' => 'get_custom_qw_field',
'output_arguments' => true, // this provides the $post and $field parameters to the output_callback
);
return $fields;
}
/*
* This is just a random custom function that returns some html.
*
* @param object $this_post - the WP post object
* @param array $field - the QW field. Useful if a field has custom settings (not shown in this example).
* @param array $tokens - Available output values from other fields
*/
function get_custom_qw_field($this_post, $field, $tokens){
// since this field is executed with "the loop", you can use most WP "template tags" as normal
// you can do anything you need here, as long as you return (not echo) the HTML you want to display.
$author = get_the_author();
// this would provide the same results
// $author = get_the_author_meta('display_name', $this_post->post_author);
return "This post is authored by: ".$author;
}
Discussion
Sorry to disturb,
I am current using “Pods – Custom Content Types and Fields” for post type creation. I have multiple file uploads on a node but only one is displayed on the wrangler.