The Template editor
This WordPress search plugin comes along with an unique template editor. With this editor, you can choose how the single result list elements will look like.
In this article, we want to discuss a little bit more the possibilities of this editor. So, the result list is actually a list, which means, it gets outputted in an unorderd list (<ul>). The single result will be outputted as a list element (<li>).
On the top of the page, you can define the basic look of these elements. So, in how many columns you want them to be displayed, and which border and background the single elements should have.
The template editor is right underneath these options. What you will find are two textareas. In the first textarea you will find the template for a single result element. In the second, you will find the template, which will be displayed in case the search didn’t delivery any results.
You can enrich the template with template tags. These template tags will be replaced dynamically. So, for example, the Tag #the_title# will be replaced by the title of the result element. You will find seven tags, which you can always use:
|#the_title#||The title of the WordPress post|
|#the_content#||The content of the post|
|#the_excerpt#||The excerpt of the WordPress post|
|#the_author#||The author of the post|
|#count_comments#||The number of comments of this post|
|#the_permalink#||The link to the WordPress post|
|#the_thumbnail#||The featured image of the post|
But, there are more tags generated dynamically. Out of every custom field and any WordPress taxonomy, you selected in the step before, there is a template tag created. Taxonomy tags start with “#tax_” and custom field tags start with “#meta_”.
By these tags, you are able to create very unique result lists and with some HTML and CSS you will be able to create beautiful lists!
Make it dynamical!
But, thats not all! These templates do understand PHP! PHP is the coding language of WordPress and by this you have are able to include the full power of WordPress into these templates. To start PHP you have to write
<?php. Everything from here till
?> has to follow the PHP coding imperatives. But with this, you have the full control!
Since the templates are run during the WordPress Query, all the functions, you know by heart from your WordPress developing can be used:
and all the other functions you know from the WordPress Codex can be used!
So with basic PHP knowledge you can say for example: If this post has the custom field “X” with the value “1”, show it in this way. If not, show it completly in another way.