Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm setting up a custom page template and I'm building a widget on it that lists albums with track lists. I use a plugin that allows me to expand text which is what I use to show tracks of the albums on click. My problem is adding the information for different artists each time. The idea is to set up the widget on the page template and then enter the guts lists items into a custom field and then calling it into the widget. The problem for me is using the shortcode from the plugin that's used inside the list items. So what I'd like to do is automatically include the shortcode before and after the child ul of a list item. I'm sure that made no sense so here's the setup.

code on page template...

<div class="albums">
    <h2 class="artist-widget">Albums</h2>
        <ul>
          <?php echo $albums; ?>
        </ul>
</div>

heres what I call in the custom field minus the shortcode that I need to insert automatically...

<li><div class="cover"><img src="" /></div><h3>header..</h3>
  [DDET see track list]
     <ol>
       <li>Intro (Album Version) 00:06</li>
       <li>What Up Gangsta [Album Version (Edited) 02:57</li>
       <li>Intro (Album Version) 00:06</li>
       <li>Intro (Album Version) 00:06</li>
     </ol>
  [/DDET]
</li>
<li><div class="cover"><img src="" /></div><h3>header..</h3>
  [DDET see track list]
     <ol>
       <li>Intro (Album Version) 00:06</li>
       <li>What Up Gangsta [Album Version (Edited) 02:57</li>
       <li>Intro (Album Version) 00:06</li>
       <li>Intro (Album Version) 00:06</li>
     </ol>
  [/DDET]
</li>

How can I get the [DDET][/DDET] in there with a function?

share|improve this question
    
What is your structure for storing the tracks vs storing the album name? –  m0r7if3r Feb 5 '12 at 12:35

1 Answer 1

up vote 0 down vote accepted

While I'm not completely sure what you're trying to accomplish, you can use the following to programatically use a shortcode:

echo do_shortcode('[DDET]Content goes here[/DDET]');
share|improve this answer
    
No I totally get that part. The problem is I can't enter php with those list items into the cutome field. When I do that it outputs the php as text. And I can't use just the shortcode obviously. I need to insert some other way. Like a function that inserts the it between and after all child ul's in that div. –  Pollux Khafra Feb 5 '12 at 6:23
    
Where are your albums coming from? Why not just place the artist in the custom field and place the list logic in the actual widget itself? –  Brian Fegter Feb 5 '12 at 6:41

Your Answer

 
discard

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.