The wgcr_search shortcode
The complete reference for the [wgcr_search] shortcode — all 24 attributes with defaults and allowed values, boolean parsing, practical examples, the PHP function and validation rules.
The [wgcr_search] shortcode renders exactly the same search field as the Elementor widget, but you can use it anywhere: inside content, in a theme template or in another plugin. Every attribute is optional.
[wgcr_search]
[wgcr_search source="course" limit="9" columns="3" mode="page"]
[wgcr_search terms="category:12,category:18" terms_op="include" date="year"]
Complete attribute table
| Attribute | Default | Allowed values | Description |
|---|---|---|---|
source | post | Any public, searchable post type | The source of results |
placeholder | Automatic | Any text | When empty: “Search posts…”, or “Search courses…” for course |
limit | 5 | A number 1 to 50 | Results per page |
columns | 1 | A number 1 to 6 | Only with mode="page" |
masonry | no | yes / no | Only with mode="page" |
equal_height | no | yes / no | Only with mode="page" and when masonry is off |
thumb | yes | yes / no | Show the thumbnail |
excerpt | yes | yes / no | Show the excerpt |
all | “Show all results” | Any text | Label of the link to the full results page |
template | 0 | An Elementor template id | Render results with a custom template |
mode | modal | modal / page | Display mode of results |
orderby | relevance | relevance, date, title, author, rand, menu_order | Result ordering |
order | DESC | DESC / ASC | Sort direction |
date | all | all, week, month, year | Date range |
terms | Empty | [taxonomy:]id, comma separated | Category or tag filter |
terms_op | exclude | include / exclude | Include or exclude |
ignore_sticky | yes | yes / no | With no, sticky posts come first |
query_id | Empty | A simple key (sanitize_key) | For the wgcr_search_query_args/{query_id} filter |
pagination | none | none, numbers, prev_next, load_on_click, load_on_scroll | Pagination type |
spacer | no | yes / no | Extra space before pagination |
more_text | “View more posts” | Any text | Label of the “load more” button |
more_icon | yes | yes / no | Icon on the button |
more_id | Empty | Letters, numbers, - and _ | HTML id of the button |
no_more | “There are no more posts.” | Any text | Message shown at the end of results |
Boolean values
The four words yes, 1, true and on are treated as true; everything else is false:
[wgcr_search thumb="1"]
[wgcr_search thumb="true"]
[wgcr_search thumb="on"]
[wgcr_search thumb="yes"]
Examples
A simple search across posts
[wgcr_search]
A course search with a three-column grid
[wgcr_search source="course" mode="page" limit="9" columns="3" equal_height="yes"]
Results only from two specific categories
[wgcr_search terms="category:12,category:18" terms_op="include"]
Last year's results with numbered pagination
[wgcr_search date="year" orderby="date" pagination="numbers" limit="12"]
Results with an Elementor template and equal height
[wgcr_search mode="page" template="42" columns="2" equal_height="yes"]
Excluding a tag
[wgcr_search terms="post_tag:7" terms_op="exclude"]
Using it from PHP
The shortcode is backed by a public render function you can call directly:
echo wgcr_search_render(
array(
'source' => 'post',
'limit' => 6,
'mode' => 'modal',
'columns' => 1,
),
'homepage'
);
| Argument | Type | Notes |
|---|---|---|
$args | array | The same keys as the shortcode attributes |
$id | string | A unique identifier; when empty the plugin generates sc1, sc2, … |
The $id argument matters when you render several searches on one page from PHP: each instance needs a unique root id, otherwise the panels conflict.
Differences from the Elementor widget
| Feature | Widget | Shortcode |
|---|---|---|
| Style controls | Full Elementor panel | None (style with CSS) |
| Columns | 1 to 3 | 1 to 6 |
| Default items per page | 12 | 5 |
| Default display mode | List mode | modal |
| Template choice control | Yes | With the template attribute |
| Query ID | Yes | Yes |
| Works outside Elementor | No | Yes |
Because the shortcode has no style panel, its output relies on the classes on the styling page plus the more_text, more_icon and more_id attributes for the load-more button.
Value validation
Nothing you write reaches the query unfiltered:
| Attribute | Validation |
|---|---|
source | Only public, searchable post types; attachment and elementor_library are excluded; anything else becomes post |
limit | Cast to an integer and clamped to 1–50 |
columns | Clamped to 1–6 |
mode | Only modal or page |
orderby | A whitelist of six values, otherwise relevance |
order | Only ASC or DESC |
date | Only all, week, month, year |
terms | Each item is parsed and cast to a positive integer |
terms_op | Only include or exclude |
query_id | Passed through sanitize_key |
more_id | Only letters, numbers, - and _ |
| Text attributes | Escaped for the attribute or HTML context they are printed in |