• Resolved AdventureLaurie

    (@adventurelaurie)


    I want to have a drop down menu of podcast episodes (category podcasts).

    See thread here

    I don’t know PHP, but this code in the above thread does exactly what I want to do and I’ve implemented it. However, I need to truncate the post title string to 20 characters. I’m guessing I need something like substr ($title,0,20) but don’t know where in this code I can truncate without breaking. Any PHP help out there?

    Thanks,
    Laurie
    My site is DailyAdventureTales.com

    I can’t leave this widget as is for very long, as it is totally wacking my mobile display. But will leave for a bit.

Viewing 1 replies (of 1 total)
  • Thread Starter AdventureLaurie

    (@adventurelaurie)

    Figured it out, here’s the code to set the number of characters in the menu. rough, not checking or adding ellipses, but works for me.

    foreach ($posts as $post) {?>
    <option value=”<?php echo get_permalink($post->ID);?>”><?php echo substr($post->post_title,0,20);?></option>
    <?php }

Viewing 1 replies (of 1 total)
  • The topic ‘PHP truncating string question – related to prior resolved topic’ is closed to new replies.