I'm fairly new to PHP but have a load of experience with HTML and CSS over the last 18 years of creating websites. My issue is I need to create a function in wordpress that will also use shortcode within it. I've got it working to a point where the shortcode within the function will display just the text and not perform it's function. Here's what I have so far:
function artistArea($atts, $content = null) {
extract(shortcode_atts(array('number' => '#', 'photo' => '#', 'name' => '#', 'video' => '#', 'audio' => '#', 'gallery' => '#', 'bio' => '#', 'element1' => '#','element2' => '#','element3' => '#','element4' => '#'), $atts));
switch ($number) {
case '1' :
$element1 = '1';
$element2 = '2';
$element3 = '3';
$element4 = '4';
break;
case '2' :
$element1 = '5';
$element2 = '6';
$element3 = '7';
$element4 = '8';
break;
case '3' :
$element1 = '9';
$element2 = '10';
$element3 = '11';
$element4 = '12';
break;
case '4' :
$element1 = '13';
$element2 = '14';
$element3 = '15';
$element4 = '16';
break;
case '5' :
$element1 = '17';
$element2 = '18';
$element3 = '19';
$element4 = '20';
break;
default :
$element1 = '1';
$element2 = '2';
$element3 = '3';
$element4 = '2';
break;
break;
}
switch ($audio) {
case '0' :
$audioSection = ''; break;
default :
$audioSection = '
<div class="artists_audio">
<a class="lbp-inline-link-'.$element2.' cboxElement" href="#">AUDIO</a>
<div style="display: none;"><div id="lbp-inline-href-'.$element2.'" style="padding:10px; background: #fff;">[soundcloud url="'.$audio.'" params="" width=" 100%" height="166" iframe="true" /]</div></div>
</div>'; break;
break;
}
switch ($video) {
case '0' :
$videoSection = ''; break;
default :
$videoSection = ' <div class="artists_video">
<a class="lbp-inline-link-'.$element1.' cboxElement" href="#">VIDEO</a>
<div style="display: none;"><div id="lbp-inline-href-'.$element1.'" style="padding:10px; background: #fff;">'.$video.'</div></div>
</div>'; break;
break;
}
switch ($gallery) {
case '0' :
$gallerySection = ''; break;
default :
$gallerySection = ' <div class="artists_pictures">
<a class="lbp-inline-link-'.$element3.' cboxElement" href="#">PICTURES</a>
<div style="display: none;"><div id="lbp-inline-href-'.$element3.'" style="padding:10px; background: #fff;">[nggallery id='.$gallery.']</div></div>
</div>'; break;
break;
}
return'<div class="artist_enclosure">
<div class="artists_photo">
<img src="'.$photo.'" alt="'.$name.'" width="150" height="150" class="alignnone size-thumbnail wp-image-39" />
</div>
<div class="artists_name">
'.$name.'
</div>
<div class="artists_bio">
'.$bio.'
</div>
<div class="artists_media">
'.$videoSection.'
'.$audioSection.'
'.$gallerySection.'
<div class="artists_booknow">
<a class="lbp-inline-link-'.$element4.' cboxElement" href="#">BOOK NOW!</a>
<div style="display: none;"><div id="lbp-inline-href-'.$element4.'" style="padding:10px; background: #fff;">[contact-form-7 id="4" title="Lounge Artists"]</div></div>
</div>
</div>
</div>
';
}
add_shortcode('artist', 'artistArea');
Here's the shortcode that I post in a page that is working brilliantly except for the video, audio and gallery sections.
[artist number="1" photo="http://www.classiccabaret.com.au/wp-content/uploads/2013/08/moniique-e1376982930857-150x150.jpg" name="Monique Hebrard" bio="Energetic and versatile, Monique is a multi-talented singer, saxophonist, actress, and dancer. Monique has vast experience in hotel and corporate events. Her musical repertoire covers a variety of Jazz, Latin, Pop, Blues, Funk, RnB, and African." video="http://www.youtube.com/watch?v=0cDK2HTLbYg" audio="0" gallery="7" ]
If anyone can help with this it would be greatly appreaciated.