Tutorials

How to internationalise or i18n a WordPress theme or plugin

Internationalisation, or i18n, is the process of making a WordPress theme or plugin translation ready. Localisation refers to the subsequent process of translating the text strings. WordPress is used by millions of people so must provide support for a large number of languages. This tutorial aims to discuss how to internationalise your WordPress theme or …

How to internationalise or i18n a WordPress theme or plugin Read More »

How to automatically empty the trash bin in WordPress

The WordPress trash bin is automatically emptied every 30 days by default. To run this task more or less frequently, you can define a constant in wp-config.php. define( ‘EMPTY_TRASH_DAYS’, 7 ); // Empty every 7 days You can also disable trash completely by setting the constant to 0. define( ‘EMPTY_TRASH_DAYS’, 0 );

How to set the excerpt length in WordPress

The default WordPress excerpt length is 55 words. That is quite a lot of text and considering excerpts are intended to be a summary you might want to tame them. The excerpt_length filter will let you set a custom length. add_filter( ‘excerpt_length’, function( $length ) { $length = 32; return $length; }, 12 );

How to change the excerpt more string in WordPress

If an excerpt is greater than 55 words, WordPress will append a more link to the excerpt text. By default the link text is […]. The excerpt_more filter can be used to change this string. add_filter( ‘excerpt_more’, function( $more_string ) { $more_string = __( ‘Continue reading’, ‘text-domain’ ); return $more_string; }, 12 );

How to get a post count on a WordPress site

The wp_count_posts() function will return an object containing a count for each status type. $count = wp_count_posts(); The status types are publish, future, draft, pending, private, trash, auto-draft and inherit. echo $count->publish; // 82 echo $count->future; // 3 echo $count->draft; // 16 echo $count->pending; // 1 echo $count->private; // 0 echo $count->trash; // 25 echo $count->auto-draft; …

How to get a post count on a WordPress site Read More »