0

I am just toying around with wordpress and php and am stuck.

In a functions.php file in wordpress, I'm creating two basic example shortcodes using this

<?php

add_shortcode('addAudioFile', 'addAudioFile');
function addAudioFile( $atts, $content = null ) 
{
  return '<li class="audio_file">' . $content . '</li>';
} 


add_shortcode('addAudioPlayer', 'addAudioPlayer');
function addAudioFile() 
{
  return '<audio preload></audio>';
}

The first one just turns the user content into a list item, and the second just calls an instance of the plugin audio.js. As it is written,the admin panel breaks and I assume I am missing something to my syntax.

What is it??? Thanks!!!

PS one shortcode in the php file works fine, but when I add them both, it doesn't work. This is all that is in the functions file.

1 Answer 1

2

PHP does not allow to overwrite functions, so you can't have two functions with the same name. You need to rename the second one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.