Problems filtering results on post (using tablepress and code snippet)
-
I’m working on a task where I’m create a database. I’m using tablepress for the data which isn’t the problem.
I’m using the code below to allow me to use a shortcode on each post so I can do some filtering. Problem is the filtering isn’t working.
function dynamic_tablepress_by_slug_shortcode($atts) {
$atts = shortcode_atts(
array(
'table_id' => '',
'filter_column' => '0',
),
$atts,
'dynamic_table'
);
$slug = get_post_field('post_name', get_post());
if (!$slug) {
return '<p><strong>Error:</strong> Could not determine post slug.</p>';
}
$shortcode = '[table id="' . esc_attr($atts['table_id']) . '" filter="' . esc_attr($slug) . '" filter_columns="' . esc_attr($atts['filter_column']) . '" datatables_sort="false"]';
return do_shortcode($shortcode);
}
add_shortcode('dynamic_table', 'dynamic_tablepress_by_slug_shortcode');However, I still get the entire unfiltered table. I’m using this shortcode in my post.
[dynamic_table table_id="1" filter_column="0"]Any idea what may be the cause of the problem?
I’ll crosspost on the tablepress page.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Problems filtering results on post (using tablepress and code snippet)’ is closed to new replies.