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?

1 Answer 1


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.

  • 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
    Commented May 29, 2011 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
    Commented May 29, 2011 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
    Commented May 29, 2011 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.
    – fuxia
    Commented May 29, 2011 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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