Using TablePress shortcodes in eBay listings
If you use the TablePress plugin to embed tables in your product descriptions, these will not work out of the box in WP-Lister.
Instead of the actual table, you will see the plain shortcode [table id=1 /]
in your listing description. Unfortunately, the developers of TablePress only register their shortcodes using add_shortcode() when WordPress loads a frontend page, but not with the WP admin.
Hopefully, they will fix this in a future release, but as of TablePress 1.5.1, you have to add the following code to your functions.php to be able to use TablePress tables in your eBay listings:
// implement support for TablePress - https://wordpress.org/plugins/tablepress/ // usage: [table id=1 /] or [table id=1 param=value] function wplister_template_filter_fix_tablepress_shortcodes( $html, $item, $images ) { if ( ! defined('TABLEPRESS_ABSPATH') ) return $html; // match shortcodes: [table id=1 /] if ( ! preg_match_all('/\[table id=(.*)( .*)?\/?\]/', $html, $matches ) ) return $html; // trick tablepress into thinking we are on the website frontend TablePress::$controller = TablePress::load_controller('frontend'); // prevent tablepress from showing "Edit" link under the table add_filter('tablepress_edit_link_below_table', function(){ return false; } ); // loop all found shortcodes for ($i=0; $i < sizeof($matches[0]); $i++) { $shortcode = $matches[0][$i]; $table_id = $matches[1][$i]; $table_html = tablepress_get_table( array( 'id' => $table_id, 'use_datatables' => false ) ); $html = str_replace( $shortcode, $table_html, $html ); } return $html; } add_filter( 'wplister_process_template_html', 'wplister_template_filter_fix_tablepress_shortcodes', 10, 3 );
Additionally, you might want to include the default TablePress CSS styles in your style.css:
/* Table description */ .tablepress-table-description { clear: both; display: block; } .tablepress { border-collapse: collapse; border-spacing: 0; width: 100%; margin-bottom: 1em; border: none; } .tablepress th, .tablepress td { padding: 8px; border: none; background: none; text-align: left; float: none !important; } .tablepress tbody td { vertical-align: top; } /* Horizontal borders */ .tablepress tbody td, .tablepress tfoot th { border-top: 1px solid #dddddd; } .tablepress tbody tr:first-child td { border-top: 0; } .tablepress thead th { border-bottom: 1px solid #dddddd; } /* Row background colors */ .tablepress thead th, .tablepress tfoot th { background-color: #d9edf7; font-weight: bold; vertical-align: middle; } .tablepress .odd td { background-color: #f9f9f9; } .tablepress .even td { background-color: #ffffff; } .tablepress .row-hover tr:hover td { background-color: #f3f3f3; } /* Reset image layout in tables */ .tablepress img { margin: 0; padding: 0; border: none; max-width: none; }