WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want to submit a theme to the wordpress.org. when i put the define('WP_DEBUG', true); in my wp-config.php. my theme showed some errors.but i don't know how to correct theme.

Q1:Warning: Missing argument 2 for cutstr() in ....htdocs\wordpress\wp-content\themes\warm-home\functions.php on line 156. the following is my function.

function cutstr($string, $length) {
         $string =strip_tags($string);
[xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf][x80-xbf][x80-xbf]|[xf1-xf7][x80-xbf][x80-xbf][x80-xbf]/", $string, $info);  
         for($i=0; $i<count($info[0]); $i++) {
                $wordscut= '';
                $wordscut .= $info[0][$i];
                $j = ord($info[0][$i]) > 127 ? $j + 2 : $j + 1;
                 if ($j > $length - 3) {
                         return $wordscut." ...";
         return join('', $info[0]);

invoked the function line is: <p><?php echo cutstr($post->post_content,150) ?></p>.there is no Missing argument 2 . why shows the above error? how correct it?

share|improve this question

do_action( 'after_setup_theme' ); doesn’t pass any parameter. You are cutting something of the length 0 after theme setup. Why?

Plus, your registration with add_action doesn’t tell WordPress that you want two parameters. The default is one parameter.

You don’t need this call at all. If you define the function in your functions.php it will be available in the loop.

Learn the Plugin API, it isn’t so hard. :)

Always prefix you functions. Otherwise your users may get fatal errors when someone else has written a function with the same name.

If your function does what I think it does, you may have a look at my function utf8_truncate(). No regex needed.

share|improve this answer
there is no do_action() in my function? how to write the add_action function. i am sorry. i am new to programme.add_action('after_setup_theme','cutstr()');. is this right? – enjoylife May 29 '11 at 9:04
once there was an error told me.the theme registers some custom functionality in the function warmHome_setup() however this function in not hooked so the functionality is not available. Recommend hooking the theme to the after_setup_theme hook. – enjoylife May 29 '11 at 9:08
so i think if i custom a function ,i should add this line after the function"add_action('after_setup_theme','cutstr()'). so could you tell me,when i should add the add_action. thank you – enjoylife May 29 '11 at 9:09
@enjoylife I added a note about the add_action() call. Read the Codex page about filters and actions. I cannot say it better. – toscho May 29 '11 at 9:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.