Easy to implement and use custom fields for WordPress templates.
Screenshots
Basic usage - simple table with values only.
A better approach is to use key/value pairs. In this case you should use table header tags for field names.
Using 2 dimensional tables
FAQ
How to use this plugin?
Simply add table to your page between [zen-fileds] short-tags. And use zen_field()
function to output value from that table.
e.g. <?php echo zen_field(1) ?>
– will output value from second row of your table that contains values only
<?php echo zen_field(1, 2) ?> - output values from 2 dimensional tables
<?php echo zen_field('field name 2') ?> - output value from table with key names defined. Key names should be defined in `<th>` - table header tags.
<?php echo zen_field('field name 2','column 1') ?> - output values from 2 dimensional table with key names defined.
Check ‘Screenshots’ section for more details.
How to use multiple tables?
Firstly define the name of each table e.g. <table data-name="some table name">...</table>
, secondly use the table name in the last parameter of zen_field()
function
e.g. <?php echo zen_field('field name 1','column name 2', 'some table name') ?>
How to iterate over table values
The variable $zen_fields->tables
holds an array with values from all the tables on the page. You can use this variable to iterate the data. The way varies depending on table structure. You can output structure of the variable for testing using <pre><?php print_r($zen_fields->tables) ?></pre>
code.
How to report errors or submit feature requests?
You can submit an issue on GitHub page, where the main repository of the plugin is held. GitHub account is needed.
https://github.com/Grzegorzsa/zen-custom-fields/issues
How to escape output from values of the table
By default output is not escaped which allows you to echo html tags e.g. links or images. If you would like to escape your output use ‘zen_field_esc()’ instead of ‘zen_field()’ function.
How to get image src attribute
‘zen_field_src()’ function can be used to extract link from the image placed in custom field.
ChangeLog
1.16
- Fix issues with
<br>
tags in new version of WordPress
1.15
- Fix get variables outside of post loop
1.14
1.13
- Prevent from showing errors when no custom fields are defined
1.12
- Improve data iteration
- Fix problem with plugin initalization
- Add parse image source function
1.11
1.1
- Fix bugs
- Allow attributes in
<th>
element