1. Home
  2. Knowledge Base
  3. Posts Table Pro
  4. Developer documentation

Overriding text strings, labels and messages in the posts table

All text in Posts Table Pro is fully translatable in the usual way, using the translation functions in WordPress. A number of translations for commonly used languages are included in the plugin.

Regardless of which language is used on your site, you may wish to modify a particular piece of  text in the plugin, and we provide a number of hooks for this. Note that using these hooks to modify text will be global across all languages. If your site supports multiple languages (e.g. English and German) we recommend modifying the text via your translation plugin.

The main language hook provided in Posts Table Pro is posts_table_language_defaults.

posts_table_language_defaults

This filter allows you to override the default values for various items of text used within the plugin. You may wish to modify the text for the Reset button or change the ‘No matching posts’ message.

The example below changes the search box label, and the text when the table has no records.

add_filter( 'posts_table_language_defaults', function( $defaults ) { 
    $defaults['search'] = 'Keyword search'; 
    $defaults['emptyTable'] = 'Sorry, no articles currently available.'; 
    return $defaults; 
} );

Post type placeholders

Some of the language strings contain the placeholders _POSTS_ and _POST_, which are replaced automatically with the plural and singular form of the post type in the table. The default post type is post, so the placeholders would be replaced with Posts and Post. If you modify any of the strings below, you can use these placeholders and they will be replaced when the table is displayed.

Language options

Here is the full list of language strings and their defaults:

Option key Default Description
info _TOTAL_ _POSTS_ The totals message below the table. You can use the following placeholders in the message: _START_ = the current page starting position, _END_ = the current page end position, _TOTAL_ = the total number of posts, _POSTS_ = the plural form of the current post type, e.g. "posts".
infoEmpty 0 _POSTS_ The totals message when there are no posts. _POSTS_ = the plural form of the current post type, e.g. "posts".
infoFiltered (_MAX_ in total) The message shown after the total when searching or filtering is active. _MAX_ = the maximum number of available posts without filtering applied.
lengthMenu Show _MENU_ per page. The text for the ‘Show [x] per page’ dropdown menu. _MENU_ is the placeholder for the actual dropdown menu.
emptyTable No matching _POSTS_. The message when no posts are found when table is first loaded.
zeroRecords No matching _POSTS_. The message when no posts are found after searching or filtering.
search Search: The label in front of the search box.
searchPlaceholder The placeholder text for the search box.
paginate['first'] First The text for the First pagination button (if used).
paginate['last'] Last The text for the Last pagination button (if used).
paginate['next'] Next The text for the Next pagination button (if used).
paginate['previous'] Previous The text for the Previous pagination button (if used).
filterBy The label in front of the search filters.
emptyFilter No results found The message when no results are found after searching inside the filter dropdown.
resetButton Reset The text for the reset button.
totalsPlural _POSTS_ The plural form of the post type being displayed. Defaults to the placeholder _POSTS_, which is dynamically replaced by the current post type (e.g. "downloads").
totalsSingle _POST_ The singular form of the post type being displayed. Defaults to the placeholder _POST_, which is dynamically replaced by the current post type (e.g. "download").

posts_table_search_label

Allows you to modify the search label shown next to the search box above the table. Defaults to “Search:”. You can set this to an empty string ("") to hide the label.

This filter is provided for convenience, and is the same as modifying $defaults['search']  when using the posts_table_language_defaults filter.

add_filter( 'posts_table_search_label', function( $label ) {
    return "I'm Looking for:";
} );

posts_table_search_placeholder

Allows you to modify the search placeholder shown inside the search box above the table. Defaults to an empty string ("").

add_filter( 'posts_table_search_placeholder', function( $placeholder ) {
    return "Enter your keyword";
} );

posts_table_search_filter_label

Allows you to add a label before the search filters. This filter is provided for convenience, and is the same as modifying $defaults['filterBy']  when using the posts_table_language_defaults filter.

add_filter( 'posts_table_search_filter_label', function( $label ) {
    return 'Filter:';
} );

posts_table_search_filter_heading_<column>

Set the default item for the search filter dropdown list. The filter name is dynamic - replace <column> with the relevant column name.

add_filter( 'posts_table_search_filter_heading_categories', function( $heading, $table_args ) { 
   return 'Choose a category';
}, 10, 2 );

posts_table_reset_button

Allows you to change the text used for the Reset button link above the table. This filter is provided for convenience, and is the same as modifying $defaults['resetButton']  when using the posts_table_language_defaults filter.

add_filter( 'posts_table_reset_button', function( $button) {
    return "Clear";
} );

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.