0

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?

1
  • What is your structure for storing the tracks vs storing the album name?
    – mor7ifer
    Feb 5, 2012 at 12:35

1 Answer 1

0

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]');
2
  • 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. Feb 5, 2012 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? Feb 5, 2012 at 6:41

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.