Skip to content

Instantly share code, notes, and snippets.

@arkadiusjonczek
Created June 5, 2015 01:27
Show Gist options
  • Save arkadiusjonczek/d62dac3e588c96cec8b1 to your computer and use it in GitHub Desktop.
Save arkadiusjonczek/d62dac3e588c96cec8b1 to your computer and use it in GitHub Desktop.
WordPress TablePress: Search for text in table using anker link (filter rows)
<a href="" class="filter_remove">Alle</a>
<a href="" class="filter_table">Funktion X</a>
<a href="" class="filter_table">Funktion Y</a>
<a href="" class="filter_table">Nichts</a>
[table id=1 /]
<script>
jQuery(document).ready(function($) {
$('a.filter_table').click(function(e) {
e.preventDefault();
var key = $(this).text();
$('#tablepress-1').DataTable().search(key).draw();
});
$('a.filter_remove').click(function(e) {
e.preventDefault();
$('#tablepress-1').DataTable().search('').draw();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment