One WordPress theme I have recently come to like is Minimal Xpert. I had been using it for some time on the Cimbalom World Association website, but hesitated to apply it to my own site because of problems in Japanese, such as excerpts not working properly. Today I took some time to fix it, so here is an installation record for future reference.

First, install and configure it normally:

  1. Download Minimal Xpert from the Minimal Xpert website and extract it under /wp-content/themes/.
  2. Activate Minimal Xpert under Dashboard > Appearance > Themes (/wp-admin/themes.php).
  3. Configure the widgets.
  4. Configure the menu. This means the menu bar that appears directly below the site title. Add a menu named “Menu,” add the appropriate items from the pane on the left, and then select “Menu” from the “Main Nav” pull-down under “Theme Locations.”
  5. “Slides” appears above “Appearance”; add slides there. Add images as “Featured Images.” The slide title configured here is used as the caption on the actual slide.
  6. Near the bottom of the left menu is an item named “MX Settings.” Open it and configure the options as needed. Slide transitions will not take effect unless you configure them here once and click “Save Options.”

For English, that is all. As it stands, however, automatic summaries on the home page and elsewhere do not work properly. In English, it extracts 50 words from the beginning and then displays “Read More…,” but in Japanese it keeps going and may even display the entire text. This is because it identifies “words” by splitting on “spaces.” In Japanese, this can result in as many as 50 paragraphs.

The extraction is performed by the file minimal-xpert/functions/better-excerpts.php, so modify it.

First, at line 11 the sentence is split into words at ‘ ‘, and at line 12 the number of words is counted. This is meaningless for Japanese. It should be character-based, so comment those lines out and obtain the total character count with $tot = strlen($text).

In addition, at line 14 the output “$output” is built by running a for loop $words times. This is also meaningless, so comment it out. Instead, treat $words as a character count and build the output with mb_substr($text,0,$words).

Here is the resulting diff:

11,12c11,13
< $text = explode(' ', $text);
< $tot = count($text);
---
> // $text = explode(' ', $text);
> // $tot = count($text);
> $tot = strlen($text);
14c15,16
< for ( $i=0; $i<$words; $i++ ) : $output .= $text[$i] . ' '; endfor;
---
> // for ( $i=0; $i<$words; $i++ ) : $output .= $text[$i] . ' '; endfor;
> $output.=mb_substr($text,0,$words);

Next, edit minimal-xpert/post-entry.php. English was truncated at 50 words, but Japanese will be truncated at 140 characters. There are 2 changes. Here is the diff:

13c13
< <?php the_news_excerpt('50','','','plain','no'); ?>
---
> <?php the_news_excerpt('140','','','plain','no'); ?>
19c19
< <?php the_news_excerpt('50','','','plain','no'); ?>.
---
> <?php the_news_excerpt('140','','','plain','no'); ?>.

That completes the fix.

 


Related posts