• Hi there,

    I’ve read some topics here about function has_shortcode creating an error once updating to wordpress 3.6.1 ,.. i’ve found the piece of code causing it in functions.php of my theme.
    However i need this code so i can’t just comment it out i decide it’s redundant. Can someone tell me how it should be rewritten?

    Here it is:

    // check the current post for the existence of a short code
    function has_shortcode($shortcode = '') {
    		$post_to_check = get_post(get_the_ID());
    		// false because we have to search through the post content first
    		$found = false;
    	// if no short code was provided, return false
    	if (!$shortcode) {
    		return $found;
    }
    	// check the post content for the short code
    	if ( stripos($post_to_check->post_content, '[' . $shortcode) !== false ) {
    		// we have found the short code
    		$found = true;
    	}
    	// return our final results
    	return $found; }?>

    Thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You just need to rename has_shortcode in functions.php to something unique (as of WordPress 3.6, it includes a function of the same name). Then you need to update the add_action or whatever is calling your function to use the same, updated name.

    Hi man if you have notepad++ or code editor, download the file, open the function.php.
    CTRL+F and replace the has_shortcode into has_a_shortcode or something else.

    hope this help

    Devin, you de mann! Just crashed my customer’s site AlfaClear Drains and changing has_shortcode to has_a_shortcode worked perfectly to get it back up and running again!!

    Thought I was going to have to spend the rest of the day getting it back up but this took seconds!

    Thanks.

    Awesome! Works like charm!

    Thank you Scriptrunner (Doug Sparling) and Devin Lee.

    Keep it up!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Cannot redeclare has_shortcode WP 3.6.1’ is closed to new replies.