Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have some code that basically looks like this (it's more complicated, but even this example shows what I'm running into):

echo '<a href="#">TEST</a>';

However, what gets sent to the browser is not <a href="#">TEST</a>, but instead <a href="http://example.com/current-page#">TEST</a>.

Is WordPress filtering this somehow to prepend the current page URL in front of the #?

It just occurred to me that this code is being called by a shortcode, which I imagine opens up the possibility of it being filtered somehow...

share|improve this question
    
Plugins/themes all disabled? Also, what browser? Does it happen in other browsers? –  John P Bloch Nov 17 '11 at 18:12
1  
All browsers, haven't disabled plugins yet, though. It did just occur to me that it's being called by a shortcode, so I suppose that may be a problem. –  tnorthcutt Nov 17 '11 at 18:20
    
Are you sure it's what is really happening (link changed in page source) rather than what is browser displaying to you? As per answer it is expected of browser to interpret such link as link to current page with anchor. –  Rarst Nov 21 '11 at 22:57

1 Answer 1

up vote 3 down vote accepted

Just ran that exact code snippet on WP 3.3 to test. In practice, <a href="#">test</a> is rendered in the markup correctly, but the browser will attempt to navigate to http://example.com/current-page/# when you hover over the link or click on it.

This is the expected behavior of a link like this ... so unless you have other code on the page that's actively changing the links, this is what I'd expect to see.

Tested under both Chrome and IE just to make sure I wasn't crazy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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