0

Wondering if anyone can help me out... here is my custom theme shortcode:

add_shortcode('toggle', 'shortcode_toggle');
function shortcode_toggle( $atts, $content = null ) {
extract(shortcode_atts(array(
    'title'      => '',
    'class'      => '',
), $atts));

$out .= '<h5 name="' .$title. '" class="toggle '.$class.'"><a class="togglelink" href="#">' .$title. '</a></h5>';
$out .= '<div class="toggle-content">';
$out .= '<div class="block">';
$out .= do_shortcode($content);
$out .= '</div>';
$out .= '</div>';

return $out; }

This is located in my themes functions.php file. I want to be able to echo the title that is entered in for the toggle in the

<h5 name=" '.$title. '">

... but I need it to strip out all characters and formatting (no spaces/symbols etc)...

Any ideas?

Thanks!

  • If you strip out "all characters" you have an empty string. Exactly what do you want to strip? – s_ha_dum Sep 6 '13 at 16:47
1

@Ravs... got it with this:

$title = sanitize_title($title);

Thank you for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.