开发者 |
codeforthepeople
johnbillion s1m0nd simonwheatley |
---|---|
更新时间 | 2013年4月13日 01:25 |
PHP版本: | 3.4 及以上 |
WordPress版本: | 3.5 |
版权: | GPL v2 or later |
?s=polly&post_type=pet&category=bird
. (You don't even have to display a faceted search form on your site to benefit from these, by the way).
Please note - Facetious isn't a replacement search engine; it helps you construct the search query, but then it's over to WordPress to run the actual search.
About
Facetious is a product of Code For The People Ltd, and is based on work done during 2012 on behalf of several UK public sector clients, among them:
facetious( $args )
. If you want to ensure the site doesn't break if the Facetious plugin is deactivated, you can use do_action( 'facetious', $args );
instead.
'$args' is an array of arguments thus:
submit
- string - The text for the submit button.echo
- boolean - Whether to echo the form out or not.class
- string - The class name for the form.id
- string - The ID attribute for the form.fields
- array - A list of fields to show in the form. See below.s
, m
or pt
for the keyword search input, month dropdown and post type dropdown respectivelylabel
- string - The descriptive text for this field. Defaults to the name of the taxonomy, or 'All types' for post types..class
- string - The class name for the field.id
- string - The ID attribute for the field.all
- string - The "All items" text for this field. Defaults to the 'all_items' label of the taxonomy.options
- array - For a taxonomy provide an array with the term slug as the key and the term name as the value, e.g. array( 'term-1' => 'Term 1', 'term-2' => 'Term 2' );
, for post type supply an array of post type names.do_action( 'facetious', array( 'submit' => 'Search', 'fields' => array( 's', 'category', 'custom_tax_1', 'custom_tax_2' ) ) );
Example 2:
do_action( 'facetious', array( 'submit' => 'Search', 'fields' => array( 's', 'custom_tax_1' => array( 'label' => 'Select an option', 'class' => 'my_tax_class', 'id' => 'my_tax_id', 'all' => 'All terms' ) 'custom_tax_2', 'm' ) ) );
Yep.
Fork me on GitHub! We welcome pull requests.
options
value in a field for either post type or taxonomy