Blog Web Development Wordpress

WordPress the_excerpt() not working with Chinese Text

WordPress’ excerpt is pretty useful, if the article doesn’t have predefined text as excerpt, it would  automatically create one using the first 55 words from your post to make one for you.
If the original text is:

The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother’s keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee.

The generated excerpt would become:

The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother’s keeper and the finder of… Read More

It’s great when you’re lazy like me, but what’s not so great is IT DOESN’T work with Chinese text, because it uses the spaces in your sentence to define words, since Chinese text doesn’t use spaces like that, it doesn’t work. The only solution I’ve found is to use the following instead of “the_excerpt();”

 $content = get_the_excerpt();
 $trimmed_content = mb_substr($content, 0, 54)."<a href=". get_permalink() ."> ...Read More</a>";
 echo $trimmed_content;

This works by first retrieving the original excerpt, using the mb_substr PHP function to get the first 55 characters from the excerpt and link it with “…Read More”. If you would like a longer excerpt, simply change 54 (In programming, you start counting from zero) to your desired number.
The main flaw to this function is that if you mix chinese and english articles it won’t be able to tell the difference and end up only giving you the first 55 characters. So that will become

The path of the righteous man is beset on all sides by… Read More

If you have a better way to tackle this, please do share it with the rest of us.
Credits to this Stack Exchange post and yes that is a quote from Pulp Fiction 🙂

Blog Startups Web Development Wordpress

My Startup Project:

Several months ago, I had the idea of developing, a website that promotes sports and fitness as well as provide a comprehensive listing of all Sports clubs, Yoga studios, Martial Dojos and Training Gyms available in Hong Kong. I wanted to build this website because I’ve been wanting to work on my own project for sometime now and I do firmly believe it is a genuine solution for individuals looking to be healthier but are struggling to make it happen, my leap of faith presumption is if people find an activity they enjoy, they would actually stick with it.

I love feeling good and hate getting headaches

The title might be true for many people, but how many are willing to do something about it. There’s always too much work, not enough tired, too tired, a good show is on TV, have to waste time on the internet and play that game on my phone. I personally love that feeling of pure bliss after a good training session or a fun game of badminton, I would rather have that then to give my any of the excuse above. I’m hoping others will feel the same way with the help of useful and interesting health related information through the platform.

Will it work?

Frankly, i have no idea if this idea would work or not, but i am going to give it a good shot. First month alone after the soft launch, I had over 500 unique visitors, which I think is a pretty good for zero marketing .

Phase 1: the ugly baby I love

I would openly admit, the current version of is built using a premium wordpress theme as base and was heavily customised to fit my needs. It’s pretty darn ugly, doesn’t exact “sell” and has performance issues, but at least it’s out there, as said many times “Better done than perfect”, this is an MVP to test reaction and I think so far it’s relatively positive, enough to convince me to move forward with it.
Big Thanks to my friend Kenny Li for making me push this out.

What’s next?

I’m currently trying to apply for some funding for the project, with or without funding, I am determined to make it happen.  Moving forward my aims are

  1. Develop high quality contents (Text articles and Infographics)
  2. Expand listing for gyms
  3. Get gyms to sign up for premium plans
  4. Redesign the site (Really want to do this NOW, but content is King, so most work on that first)

What do you think?

So what do you think about so far? I would love to hear your thoughts using the form below.

Blog Tools & Services Web Development Wordpress

Appointments and Meetings management with WordPress

After my previous post on WordPress Booking Systems I am once again on the look out for a suitable plugin to help me manage appointments and meeting’s for a client.
The WP Booking Calendar plugins I reviewed before was very good at the job but not wanting to settle for what I already know, I went hunting for something more comprehensive. And that’s when I came across WPMU’s Appointments plugin, now it’s NOT FREE. But it is pretty powerful and flexible, aside from the usual ability to allow clients to make bookings and pay, two key function I just love is its ability to sync with Google Calendar and send user email reminders! How cool is that? So in a way it’s more than just a appointment management system but also a personal assistant which I think it’s pretty darn cool.

WPMU Appointmentswpmu-appointment-booking2

Another plugin I looked at is the JS-Appointment Calendar (No longer available) from CodeCanon, again it’s paid at $25 USD at the time of writing, so not the cheapest but it does look like it could be perfect. However, since I already have membership with WPMU, I will test out WPMU’s Appointments first. But good one to check if you are interested.
Let me know if you have any questions on any of these appointments and meetings WordPress plugins. Better yet, if you know of similar tools I should look into, please comment below!
*In case anyone is wondering what that image I used for my featured image is, it’s actually an cropped area of an traditional Chinese daily calendar.

Blog Web Development Wordpress

Reminder for creating custom WordPress sidebars

This is one I keep on forgetting and have to Google on numerous occasions, so I’m adding it to my blog as a reminder.  I like to refer to the Sidebar in WordPress blog by Justin Tadlock, it’s old, written in 2010, but as far as I can see it still work.
There’s 3 parts to creating a custom Sidebar:

  1. Creating the Sidebar PHP file
  2. Registering the Sidebar in functions.php
  3. Adding the sidebar in the page template

1.Creating the Sidebar PHP file

Assuming you want to create a new sidebar called “Special” Duplicate the sidebar.php from your theme and rename it to sidebar-special.php

2.Registering the Sidebar in functions.php

Open the theme’s function.php file and search for my_register_sidebars it should look similar to the following:

add_action( 'widgets_init', 'my_register_sidebars' );
function my_register_sidebars() {
	/* Register the 'primary' sidebar. */
			'id' => 'primary',
			'name' => __( 'Primary' ),
			'description' => __( 'A short description of the sidebar.' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>'
	/* Repeat register_sidebar() code for additional sidebars. */

Paste the following lines after /* Repeat register_sidebar() code for additional sidebars. */

		'id' => 'special',
		'name' => __( 'Special' ),
		'description' => __( 'My custom made special sidebar.' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>'

3.Adding the sidebar in the page template

In your custom page template, replace get_sidebar(); with get_sidebar('special')
And that should do the trick, But remember to add items in your widgets page.

Blog Wordpress

WordPress Booking system

UPDATE 25/3/2013: My new article on WordPress Booking Systems 
As a “bonus” function for a project, we needed an very simple online booking/reservation system.
All I needed is a way for potential clients to see which days has already been booked, and be able to make enquiry for days that are still available.
*Disclaimer, I am NOT affiliated with any of the applications or websites mentioned below. 
The following is a list of Plugins I found, tested and deem unsuitable for my purpose.

I then found the following article which I’m very glad to say recommended Booking Calendar.
It provided a very simple way of doing exactly what I needed, and it even has a Premium Version for the extra bells and whistles if you so need them. (Again I am not affiliated in anyway and this is not an advert!)

Blog Wordpress

WordPress and Bootstrap Part2!

I have previously wrote about how much I love Bootstrap and were really looking forward to using it on my next wordpress project. Thanks to this wonderful article from Smash Magazine, I just found out about the Roots Theme which combines HTML5 Boilerplate and Bootstrap from Twitter. Which I have to say is looking very promising
So to sum up. I have the following bootstrap wordpress theme to test: