Templates are used to embed details of files in to a post or page. They are can also be used to create file lists. WP-Filebase includes a powerful template engine supporting IF-THEN-ELSE blocks. Templates are blocks of HTML code containing variables. There are three different types of templates:

  • File Templates are used to embed files
  • Category Templates are used for categories in file lists if file grouping is enabled
  • List Template consists of a Header, Footer and a File and Category Template.

Special templates that cannot be deleted:

  • Default: Default templates are used when there is no template specified, for example a shortcode without the tpl parameter. Its also used for file search results and attachments. Note that the default templates appears in the template management list as well as in settings. When resetting settings, the default template code is restored!
  • Filebrowser: template used for AJAX treeview
  • Filepage: This template is used to build the File Details Page (WP-Filebase Pro)

You can even place shortcodes into templates to build advanced file lists. Be careful: don’t nest a shortcode using the template itself!


A template is a piece of HTML code containing “variables” that will be replaced with file specific properties. A variable is wrapped by two % characters, i.e. %file_name%. A very simple template:

<img src="%file_icon_url%" style="height:20px; vertical-align:middle;" />
<a href="%file_url%" title="Download %file_display_name%">%file_display_name%</a> (%file_size%)

This would output a HTML paragraph containing a small icon/thumbnail followed by the name and size of the file.

To omit the <img> tag for files without a thumbnail, an IF-block is added:

<!-- IF %file_thumbnail% -->
<img src="%file_icon_url%" style="height:20px; vertical-align:middle;" />
<!-- ENDIF -->
<a href="%file_url%" title="Download %file_display_name%">%file_display_name%</a> (%file_size%)



Inside an IF expression you can use the Boolean operators OR and AND. The following sample inserts a link to the associated post/page of the file if: 1. the file has an associated post and 2. the currently viewed post/page is not the associated one. So the link won’t appear in templates that are generated in the post/page of the file:

<!-- IF %file_post_id% AND %post_id% != %file_post_id% -->
<a href="%file_post_url%">%'View post'%</a>
<!-- ENDIF -->

Templates are internally parsed to PHP code, so all PHP and WordPress functions can be used in expression!

Template Variables

The following template variables are available for file and category templates:

NameDescriptionTypeExample Value
%uid%A unique ID number to identify elements within a templateNumber3
NameDescriptionTypeExample Value

Here’s a list of template variables for files, which can be selected from the Drop-Down when editing a template. Custom fields (see Settings) appear at the end of the Drop-Down box.

NameDescriptionTypeExample Value
%file_name%The name of the file (with extension)numberexample.pdf
%file_size%ID of the current post or pageFormatted size1.63 MiB
%file_date%Formatted date of the file (change in Settings)Formatted date time4. May 2011
%file_thumbnail%The name of the thumbnail fileStringexample-100×120.png
%file_display_name%The Title of the fileStringExample Document
%file_description%File DescriptionString
%file_version%File VersionString2.1
%file_author%File AuthorString
%file_languages%A comma-separated list of all supported languagesStringsEnglish, German
%file_platforms%A common-separated list of supported platformsStringsWindows 7, Ubuntu
%file_requirements%A commo-sperated list of requirementsStringsApache, MySQL
%file_license%File LicenseStringCreative Commons
String (user role)Subscriber
%file_user_can_access%Boolean (0/1)0
%file_offline%Boolean (0/1)1
%file_direct_linking%Boolean (0/1)


If ID3 detection is enabled, there are more variables available for each file. ID3 variables begin with the prefix %file_info/ . Example to get artist of an mp3 file:


These variable can also be used in IF expressions. You’ll find a list of all available variables below the file form when editing a file.

Special template variables

%dl_countdown% Used in File Details Page template to display the countdown

%search_form% Used in list headers and footers to display a search form

%sort_link:file_sizeWill be replaced by a URL to sort the current file list. Example:
<a href="%sort_link:file_name%">Sort by Name</a>

%print_script:{script-name}% Used in list headers to include JavaScripts like the jQuery extension dataTables.

%print_style:{style_name}% Used in list headers to include CSS files.

Useful Expressions

Only display ads (or anything else) to non-registered users:
<!-- IF get_current_user_id() != 0 --> ..ad code.. <!-- ENDIF -->

PHP Code in Templates

WP-Filebase Pro supports PHP codeblocks inside the Template code. To use a template variable in PHP, use the following syntax (instead of %file_display_name%):
<?php echo $file->get_tpl_var('file_display_name'); ?>

55 thoughts on “Templates

  1. Dhiraj Chaudhary says:
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

    How can I place File list in FileBrowser category.
    I want to list files instead of names when user expands folder. It should also have sorting capability so want to use list.

    1. Valerie says:
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)

      On the sorting, goto WP-Filebase–>Settings from your Dashboard; then select the “Filebrowser”. The second and fourth options are for category and file sorting. I personally utilize the custom 1 & custom 2 fields in the file maintenance and then use those for sorting the files and categories.

  2. James Mark says:
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

    Is there a way to show only the Month and Year in date excluding the day?..


  3. Milos says:
    VN:F [1.9.22_1171]
    Rating: +1 (from 1 vote)

    Please i neeed emed view to pagefile template using emed view

    1) zhis is ok but only pdf and ppt

    2) how i can use

    i tried url file [gview file=”http://web1.edumag.eu/wp-content/uploads/filebase/%file_path%”]

    but not function http://web1.edumag.eu/wp-content/uploads/filebase/externi/analyza3.ppt

    here is link: http://web1.edumag.eu/?wpfb_filepage=analyza3-ppt

    Thank you…

  4. Valerie says:
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

    I’ve created a new template (“newsletter”) for the file browser; when I use it as a variable, it will not work. However, if I change the default template for the filebrowser, it works fine. I have the standard free version. Here are the two commands I tried to use:
    [wpfilebase tag=browser tpl=newsletter id=4 /]
    [wpfilebase tag="browser" tpl="newsletter" id=4 /]

  5. Shahin says:
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

    How can filter the files in table format with the category name???

  6. Colin says:
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)


    I’m trying to make the image larger when using “File List” on a page such as http://www.slotcars.wraithsobsessions.co.uk/slot-car-art/4613-2

    Can the image be made bigger, if not could I use the space by having two or three images across, if so how would this be done, or are these options limited to the Pro version?

    Many thanks in advance.


  7. Fred says:
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

    Can you add additional templates in the free version, or just the pro version? I can’t find any thing that says it’s part of the pro version. I’ve installed the free version, but there does not appear to be a way to add templates.

    1. Fred says:
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)

      OK I found the problem… the “Manage Templates” option does not show up if you’re using a security plugin that disables the file editor option. I do, so by turning off the hide file editor option, the “Manage Templates” option for this plugin showed back up.

  8. Dina says:
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)


    I am using Wp Filebase Pro and it is a really cool Plugin.

    Now I want to add in my data table template a row to display only one category ( I have 4 ) for example :

    %file_category% but only one of my categorys like category name :Animals.

    How can I address a single category (example Animals)?

    Thank you so much for your help,

    Best regards,


  9. Jeffery says:
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

    The latest update made my preferred download Template change to some thing I don’t want. I’m trying to put it back to the original default one with the rectangular border with the image on the left. There is similar one for MP-3 and when I select it and update it it won’t. I rolled back to older version and still have no results. How do I fix this. Thanks

  10. Paul James says:
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

    I have a search option in the header of the template but would like to limit the search results to a specific tags, which would match the out put of the list.

Leave a Reply

Your email address will not be published. Required fields are marked *