No special actions required to make WPML and TableOn works together, just: Install WPML Set in WPML setting the site languages Create your site content on different languages Set WPML language switcher on the site front where a TableOn table is That is all 🙂 Your site visitors now can see your site posts in […]
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 […]
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 […]
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 […]
Example of such column you can see on this page: https://demo.posts-table.com/audio-referrals/ Do next: Open 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') { //for https://demo.posts-table.com/audio-referrals/ $profile['sound_options'] = [ 'title' => 'Sound options', 'order' => FALSE, 'action' => function($post_id) { return do_shortcode("[tableon_single_btn id={$post_id} button_text='Options' columns='sound_bitrate,sound_duration,sound_year,sound_artist,sound_info' css_class='tableon-btn' help_title='How to add column Options' help_link='https://posts-table.com/how-to-add-column-with-custom-meta-fields-in-popup/']"); } ]; } return $profile; }, 10, 2); |
Register necessary meta-fields in TABLEON system by code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | //add custom meta fields not visible on TABLEON admin page to select it in sound options add_action('tableon_profile_extend', function($profile, $action_name) { $sound_keys = [ 'sound_bitrate' => 'Bitrate (kbps)', 'sound_duration' => 'Duration', 'sound_year' => 'Year', 'sound_artist' => 'Artist', 'sound_info' => 'Info', ]; foreach ($sound_keys as $key => $title) { $profile[$key] = [ 'title' => $title, 'order' => 'asc', 'display' => false, //do not display in fields list on TABLEON backend 'action' => function($post_id) use($key) { return get_post_meta($post_id, $key, true); } ]; } return $profile; }, 10, 2); |
In the table for where you want to display column “Options” create new column, name it and select field ‘Sound options’ […]
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 […]
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
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 […]