The argument “cols” is used to define your columns inside the table. If you customize the columns. It doesn’t matter if you use only some default wordpress build-in post fields (e.g. title, published, author) or if your use your own created custom post fields (e.g. in this demo database like lastname, firstname, street, ZIP, city, Logo, Vehicle, Model, Manufacturer,Country,Year,…….). Feel free to mix both types of post fields to build a professional DataTable.

Syntax

[jsdatatable cat=YourCategory cols=title,published,YourCustomField2,YourCustomField1,author]

EXAMPLE:

[jsdatatable cat=YourCategory cols=lastname,firstname,Street,ZIP,City,published]

Defaults

Without any argument “cols“, the following internal setting will be operated:

cols=title,published,author

Note

WordPress is case sensitive while using fieldnames! Take care about notation, when using the cols-argument. The default post fields your write in this manner:

THIS IS RIGHT ⇒ cols=title,published,author 
THIS IS WRONG ⇒ cols=Title,Published,Author

To handle custom post fields in the DataTable, the notation depends on how you named your own fields before! In our demo (including the cars and motorbikes) we have 7 custom post fields. All this custom post fields in the demo database we give fieldnames where the first character is a upper-case-character. Therefore of course we have to apply exact this kind of notation inside the cols-argument now:

THIS IS RIGHT ⇒ cols=Logo,Vehicle,Model,Manufacturer,Country,Year,Write-Up
THIS IS WRONG ⇒ cols=logo,vehicle,model,manufacturer,country,year,write-up

A mix (default wordpress fields and our own custom post fields) would look like this:

RIGHT ⇒ cols=Logo,title,Vehicle,Country
THIS IS WRONG ⇒ cols=logo,title,vehicle,country
THIS IS WRONG ⇒ cols=Logo,Title,Vehicle,Country


COLS ⇒ Some live examples

Please click on the links below and check out the difference:

POSUse this shortcode:Note
03jsdatatable CAT=all COLS=Vehicle,title,Year
05jsdatatable CAT=all COLS=Logo,Manufacturer,Vehicle,Modelonly custom post fields inside col-argument
04jsdatatable CAT=all COLS=Vehicle,Model,Manufacturer,Year,published,authormix of both in col-argument (makes no difference)
02jsdatatable CAT=all COLS=title,published,authoronly wp build-in fields inside col-argument
01jsdatatable CAT=alldefault (title ,published, author)
06jsdatatable CAT=all COLS=Logo,Manufacturer,Vehicle,Model,Year,Write-Up