0

I am no beginner Wordpress developer by any means but I am completely stuck with this. I have tried an array of alternatives without any result (href="#", href="#void", etc.).

I need "javascript:void(0);" as the href attribute in a HTML link. Inserting this in the text editor, flicking to the visual then back to the text editor makes it disappear.

I have read up some information on it (re: esc_url) but can't seem to find a fix. Is there a way for me to make this work on a Page in Wordpress somehow by way of a function or script?

The link I am trying to generate is: <a href="javascript:void(0);"> subscribe </a>

Thanks in advance.

  • 1
    Can you explain why do you need this. There are too many ways to achieve the goal: a plugin, data-* attribute and jQuery, hardcoding in the template upon some condition, custom field, disabling content filtering (very bad idea) and many more. – Max Yudin Jul 2 at 10:29
  • I agree with Max, this shouldn't be necessary. This answer from SO is a good explanation of why: stackoverflow.com/a/1293130 – Jacob Peattie Jul 2 at 12:11
  • Thanks peeps. I tried the link without the href in it and it actually worked fine. I can't believe I wrecked my head over this. 🙄 – lightpurpple Jul 4 at 14:40

Your Answer

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

Browse other questions tagged or ask your own question.