0

I have the following piece of PHP code as part of my site theme. Where I am stuck is, if the value of $sec_title contains an apostrophe, then the text doesn't display. But without an apostrophe, it contains fine. How can I amend this to prevent this issue?

<?php
if ( $sec_title ) {
echo do_shortcode( "[onex_section_header
title={$sec_title}
subtitle='{$sec_subtitle}']"
);
} ?>

1 Answers1

0

Try using:

$sec_title = addslashes($sec_title)

before you echo or try switching the double and single quotes around as so

echo do_shortcode('[onex_section_header 
title={$sec_title} 
subtitle="{$sec_subtitle}"]'
);
eeetee
  • 502
  • 4
  • 14