For example you added to the table meta key ‘_regular_price’. By default it will be displayed as simple number or string. But what about if you want to format it and display with even another information near? Overload its output! In file functions.php of the current WordPress theme add next code:
| add_action('tableon_profile_extend', function($profile, $action_name) { if ($action_name === 'tableon_default_tables') { if (isset($profile['_regular_price'])) { $profile['_regular_price']['action'] = function($post_id) { return format_price(get_post_meta($post_id, '_regular_price', true)); }; } } return $profile; }, 10, 2); |
format_price here is […]
If you want to add button which link to any external information about a post: in file functions.php add next code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | add_action('tableon_profile_extend', function($profile, $action_name) { if ($action_name === 'tableon_default_tables') { $profile['ref_btn'] = [ 'title' => esc_html('Ref. button'), 'order' => FALSE, 'action' => function($post_id) { return TABLEON_HELPER::draw_html_item('a', [ 'href' => get_post_meta($post_id, '_product_url', true), 'target' => '_blank', 'class' => 'tableon-btn' ], 'BUTTON NAME HERE'); } ]; } return $profile; }, 10, 2); |
ref_btn is just name of key for TableOn profile, you can use your own one. _product_url in the code is the meta key with the link, of course you can use your own […]
Use hook tableon_gallery OR use meta key ‘tableon_gallery’ and keep there image attachments ids as string, example: 23,77,99
In file functions.php of the current WordPress theme add next code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | add_action('tableon_profile_extend', function($profile, $action_name) { if ($action_name === 'tableon_default_tables') { $meta_key = '_my_marks'; if (isset($profile[$meta_key])) { $profile[$meta_key]['action'] = function($post_id) use($meta_key) { $mark = get_post_meta($post_id, $meta_key, true); if ($mark) { return "<span class='tableon-html-yes'><i class='tableon-icon'></i></span>"; } return "<span class='tableon-html-no'><i class='tableon-icon'></i></span>"; }; } } return $profile; },10,2); |
Do not forget to replace meta key in the code ‘_my_marks’ to your own one. So instead of displaying 1 or 0 relevant icons will be displayed. Sure by CSS you can display your own icons instead. Also read: https://posts-table.com/how-reload-meta-display-in-the-cell/
You can see results on the top menu of the site https://demo.posts-table.com/ -> click on ‘Hottest Posts’ Do next: Create on TABLEON admin page new shortcode [tableon] Open settings of the new shortcode -> tab ‘Predefinition’ -> ‘Posts ids’ -> Using comma, set posts ids you want to show in the table. Example: 23,99,777. Set […]
Yes. It is possible to add your own custom functionality and use it as shortcode. Example: (add next code to file functions.php)
| add_shortcode('tableon_my_custom_button', function() { tableon()->include_assets(); return TABLEON_HELPER::draw_html_item('a', array( 'href' => 'javascript: tableon_helper.call_popup("call_action_custom1",{a:1,b:2,c:"hello",not_paste:1},"asd","Hello World 2020!!"); void(0);', 'title' => '', 'class' => 'tableon-btn' ), 'click on this button'); }); add_action('call_action_custom1', function($args, $call_id) { print_r($args); return "It is custom action in functions.php"; }, 10, 2); |
Results: button, on click shows popup with data
Using FULLTEXT indexing will in increase the speed of posts searching by its title. Do next: open your site database using phpmyadmin page enter to your site database find table “wp_posts” click on tab “Structure” find field “post_title” find on the right side and click “More” -> “Fulltext” on the popup click OK and wait […]
You need to create custom shortcode to combine the tables in one place. In file functions.php add next code:
| add_shortcode('tableon_set_1', function() { return tableon()->do_set([ ['title' => 'Alicante', 'content' => '[tableon id=1]'], ['title' => 'Madrid', 'content' => '[tableon id=3]'], ['title' => 'Barcelona', 'content' => '[tableon id=4]'], ]); }); |
Titles here means tabs titles.
Search-input can be placed to the site header or into the page content text. Use shortcode [tableon_drop_down]. create new TABLEON table on the plugin backend set all necessary options you want for the table open page where you want to place shortcode drop into the page content shortcode [tableon_drop_down id=7] where 7 is ID of the […]
Use hook tableon_profile_extend for it. For this in file functions.php add next code:
| add_action('tableon_profile_extend', function($profile, $action_name) { if ($action_name === 'tableon_default_tables') { $profile['my_new_column'] = [ 'title' => TABLEON_Vocabulary::get('My new column'), 'order' => FALSE, 'action' => function($post_id) { return 'Hello World!'; } ]; } return $profile; }, 10, 2); |
Using $post_id you can create any data and return it directly to the cell. Lets review more complicated example demonstrated here. Make your attention on button “Ask Me”, click on it. As you can see this is contact form where customer […]
Use hook tableon_profile_extend for it. Here is some examples: Lets add referral button to the table:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | add_action('tableon_profile_extend', function($profile, $action_name) { if ($action_name === 'tableon_default_tables') { $profile['refferals'] = [ 'title' => 'Refferal btn', 'order' => FALSE, 'action' => function($post_id) { $refferal = 'demo'; return TABLEON_HELPER::draw_html_item('a', [ 'href' => "https://demo.posts-table.com?ref={$refferal}&post_id={$post_id}", 'class' => 'tableon-btn', 'target' => '_blank' ], 'Get it for free'); } ]; } return $profile; }, 10, 2); |
This is good for external posts you promoted on your site Also you can get referral link in another way, for example take if from the post metadata
Go to TABLEON settings Find row ‘Fonts’ Use comma and do not use quotes! Example: Helvetica,Roboto Use fonts which are represented in the current WordPress theme!
Create posts tables for each category you want to show In the each created table: settings -> tab “Predefinition” set rule “Included taxonomy” Create pages and paste created shortcodes there
TABLEON tables has inbuilt search input for searching by posts title, which not belongs to filter constructor, and its position is always on the top. Visibility of the search input managed by option in the tab “Options”: The search input is synchronized with the “Filter” functionality but its position is not changeable. So, if the […]
Yes! If content of the cell is constant – it is possible use generated CSS class as on the screen: hashXXXXXX Also each cell has CSS class, dependent of the field of the current table cell Also table cell has data-attributes: data-pid, data-key, data-field
| td[data-pid="13287"][data-key="price"]{ background: red; } td[data-pid="14281"][data-key="price"] { background: green; } |
As you can see above using 2 data-attributes allows targeted […]
Use tab “Meta” in the table tools popup. Also you can add it by code. Use next code in file functions.php:
| add_action('tableon_profile_extend', function($profile, $action_name) { $profile['hmeta_1'] = [ 'title' => TABLEON_Vocabulary::get('Meta 1'), 'order' => 'asc', 'display' => false, //display in fields list in the settings 'action' => function($post_id) { return get_post_meta($post_id, 'meta_1', true); } ]; return $profile; }, 10, 2); |
Trough code you can use custom columns in such shortcode [tableon id=49 columns=’id,title,__price,hmeta_1′] Also for some tables it is possible to modificate results in the table cell:
| add_action('tableon_meta_data_cell', function($value, $meta_data, $post_id, $table_id) { if ($meta_data['meta_key'] === 'meta_1' AND $table_id === 21) { $value = floatval($value) * floatval(get_post_meta($post_id, 'meta_2', true)); } return $value; }, 10, 4); |
This code for table 21 in […]
If to use sorting by meta keys – will be visible only posts which has any value for the selected key. This behavior is peculiarity of WordPress engine. Here is an article about how to resolve it: https://wordpress.stackexchange.com/questions/102447/sort-on-meta-value-but-include-posts-that-dont-have-one
2 ways here: Use tab Vocabulary Use hook tableon_lang_load_more
If you want to place posts table into the page created by Elementor you should add next code into the file functions.php of the current WordPress theme:
| add_filter('run_wptexturize', function() { if (is_page(13778)) { return false; } return true; }); |
13778 in the code – is the page ID, where you want apply TABLEON tables and Elementor constructor.
Remote page with the posts table can be created on any another site, for example sites of your partners where they spread your posts as referrals. Not depends on CMS and can be placed even on a simple HTML template page. See inbuilt posts table in simple HTML template here. To create: create page on […]
You can wrap some shortcodes into your custom one. Do next: open file functions.php of the current WordPress theme paste and edit there next code:
| add_shortcode('my_tableon_1', function($args) { $user = wp_get_current_user(); if (in_array('administrator', $user->roles)) { return do_shortcode('[tableon id=23]'); } elseif (in_array('shop_manager', $user->roles)) { return do_shortcode('[tableon id=29]'); } else { return do_shortcode('[tableon columns="id,post_title,__price"]'); } }); |
paste shortcode [my_tableon_1] to page you want also make your attention to $args – you can make custom shortcode attributes On this way you can create different custom shortcodes […]
Use hook tableon_profile_extend. Example: add next code to file functions.php of the current WordPress theme
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | add_action('tableon_profile_extend', function($profile, $action_name) { if ($action_name === 'tableon_default_tables') { $meta_key = 'my_global_column';//important! $meta_data = [ 'title' => TABLEON_Vocabulary::get('My meta column'), 'meta_key' => $meta_key, 'meta_type' => 'text', //text, number, calendar ]; $profile[$meta_key] = tableon()->columns->meta->assemble_meta_for_system($meta_data); } return $profile; }, 10, 2); |
In code replace your meta key in variable $meta_key and change column title (My meta column). Make your attention on metadata types: text number calendar
If you need to modificate output of any field predefined in TABLEON you can use next code:
| add_action('tableon_profile_extend', function($profile, $action_name) { if ($action_name === 'tableon_default_tables') { $profile['__sale']['action'] = function($post_id) { $meta=get_post_meta($post_id, '__sale', true ); return $meta ? "<span class='your-class-here'>Yes</span>" : "<span class='your-class-here'>No</span>"; }; } return $profile; }, 10, 2); |
In the example you can see output modification of the meta column ‘__sale’.