0

The Problem

The theme I'm using allows one, in its options, to enter some contact info to be put in the header. The demo content has an empty link like this: <a href="#">Random Shit</a>.

What I'm trying to do is to put a mailto in it, such as:

<a href= "mailto:contact@example.com">contact@example.com</a>

but the theme adds double quotes around href's content corrupts it to something like this in the front-end:

<a href=""mailto:contact@example.com"">contact@example.com</a>

So when a user clicks it, they're redirected to example.com/currentpage/"mailto:contact@example.com"

Possible solutions:

  1. Look for the code that handles the options (takes too long, the code is badly written)
  2. ?

If you have stumbled upon a similar problem please share your experience, whether you found the solution or not.

  • there are 2 other options... Ask the theme developer to address this issue OR change themes – rudtek Jan 29 at 16:11
  • Those were the two options I considered first, but sadly, the theme developer asks for access to our website's administration and I can't do that. And management won't approve of changing themes because it looks good, and we don't have time to work on another one. Thanks @rudtek – Mahboubi Salim Jan 29 at 16:15
  • Fair enough, but I would stress to your management that this type of error in coding could very well be indicative of further problems and will cost more in the long run. – rudtek Jan 29 at 16:22
0

Just after posting the question I tried to remove the quotes from the href in the theme options and it worked.

<a href=mailto:contact@example.com>contact@example.com</a>

Another solution I considered was to use .htaccess redirects in a way such it redirects to whaterver the theme decided to point to a mailto:

Redirect 301 /[path-to-wherever-metallex-points-to] mailto:contact@example.com -solution 2 source-

So if you find yourself in a similar situation, you have the choice between two solutions.

  • that code isn't correct. You need 1 set of quotes. – rudtek Jan 29 at 16:12
  • It's not correct when you input it in the options, but it works because the theme adds a set of quotes whether they're present or not. I really don't see why a developer wasted their time to parse options HTML to add quotes and screw it up. I'm just trying to make it work. – Mahboubi Salim Jan 29 at 16:19

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.