Hi tritongr,
The “question” uses WordPress’ sanitize_text_field() function, meaning that it strips all tags for security. However, it uses the default get_the_title() function to display. What this means is that when it saves a title, it strips out any tags, but when it displays the title, it will only strip out things that you cannot use in a post or page title.
STEP 1: test!
I don’t have time to test myself right now (and cannot remember off hand what tags WordPress allows by default), but first, create a normal post or page, and set the title of that post or page to something that uses <br/> and <sup> tags. Preview the post or page and see how the title displays. If WordPress strips out those tags, then I’m afraid we might be out of luck for an “easy” solution. If, however, WordPress does not strip the tags, then there is an easy (and temporary) solution for you below.
STEP 2: modify!
If you are comfortable editing some code, you can edit one line of the /includes/functions.php file to get this working for you until I code in a permanent solution. Just please note that the following removes sanitation for the question title – so be careful about what you use as titles and make sure only people you absolutely trust have access.
Line 491
$title = sanitize_text_field($_POST['title']);
becomes
$title = $_POST['title'];
That’s it! It should for you now.
Everything worked!
Your answers are always clear and easy to follow.
After changing the 491 line as you suggested, I was able to enter <br />, <sup> and <u> tags in the question area.
Thank you!
Allow me a relative question.
Do you think it is possible to inject/concatenate somehow somewhere near the question_id the <span style="color:red;"> or in css, in order to have the question’s hash and number in red?
Thanks
I got you friend!
Add the following jQuery and CSS to the footer of your site.
<script>
jQuery(document).ready(function() {
jQuery(".hdq_question h3").each(function() {
let hdq_title = jQuery(this).html();
hdq_title = hdq_title.split("#");
if (hdq_title.length === 1) {
// question as a title
hdq_title = hdq_title[0];
} else {
// numbered question
hdq_title = hdq_title.join("#");
hdq_title = hdq_title.split(" ");
let hdq_title_new =
'<span class = "hdq_question_tile_number">' + hdq_title[0] + "</span> ";
hdq_title.shift();
hdq_title = hdq_title.join(" ");
hdq_title = hdq_title_new + hdq_title;
}
jQuery(this).html(hdq_title);
});
});
</script>
<style>.hdq_question_tile_number {color:red}</style>
This is magic!
Yes now all numbering is red.
This is really premium level support
Thanks a lot!