WordPress Customization

WordPress Customization to achieve minimalist, user friendly and fast response site!

WordPress Limit Post Excerpt By Characters Without Truncation
Customizing Arrow for Newer Older Entries
Auto Resizing Posts Pages Image by Max Width Height
Customizing Breadcrumb NavXT WordPress Theme
Optimizing Robots.txt for Better SEO

WordPress Limit Post Excerpt By Characters Without Truncation

Ayumilove.net homepage post excerpt had some makeover to reduce text bloat. Post excerpt is a snippet of your post first few sentences. The excerpt is Twitter-styled by limiting it to 240 characters. Below is the code I used in my theme functions.php which might be useful for your WordPress-based site.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// [AYUMILOVE_START] Twitter Style Post Excerpt
function get_twitter_style_excerpt(){
$excerpt = get_the_content();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, 240);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
$excerpt = $excerpt . '...';
return $excerpt;
}
add_filter('the_excerpt', 'get_twitter_style_excerpt');
// [AYUMILOVE_END] Twitter Style Post Excerpt

Customizing Excerpt Notes
1. The code above does not truncate last word if meets max characters. Example:
1a. Original Statement = The quick brown fox jumps over the lazy dog.
1b. Truncated Statement = The quick brown fox jumps ove …
1c. Truncation fix = The quick brown fox jumps …
2. Change character length 240 to the length you are comfortable for your excerpt.
3. If the excerpt is not styled with css, add the paragraph tags < p >
4. Implementing this code into Theme functions.php avoids installing plugin.

Customizing Arrow for Newer Older Entries

Instead of using mini triangle .gif pictures to highlight the direction of your newer and older entries, you could use the HTML arrows to do it. Below is an example of adding arrows to your main index.php and your post.php
Continue reading

Setup Akismet Plugin using WordPress Akismet API Key

Setting Up Akismet Plugin In Self Hosted Website. Get free akismet api key to activate akismet plugin to block spam comments in your self hosted website/blog. To obtain the free aksimet api key, follow the steps below:

1. Create a wordpress.com account (if you do have an existing one, log in)
2. Visit https://apikey.wordpress.com/
It will display your username and API Key. Below is an example:
Your WordPress.com username is “username” and your API key is “randomAlphanumeric”.