1

I have an image which serves as an a href, the following a href doesn't work:

<div id="buttonNext">
    <a href="1-5/redrum-10">
        <img id="buttonNextImg" src="../../resources/img/buttonImg/next.png"/></a>
</div>

Me clicking on the link results in me being redirected to this website:

http://localhost/redrumwordpress/wordpress/redrum-10/

which also exists, but it doesn't link me to the correct website, the following code does work and links to the correct website:

<div id="buttonNextBottom">
    <a href="1-5/redrum-5/">
        <img id="buttonNextImgBottom" src="../../resources/img/buttonImg/next.png"/></a>
</div>

Which re-directs me to the correct page:

http://localhost/redrumwordpress/wordpress/1-5/redrum-5/

I've checked if I missed something like a / or ../ maybe it was in the wrong folder. I've checked for the file not being there, but it is and it isn't corrupt.

Could anyone help me with why WordPress won't link to the correct website, when I use this website outside of wordpress it works just fine.

  • Somewhat confused by your situation. When you say "... when I use this website outside of Wordpress..." especially. Are these URLs WordPress generated pages with permalinks? I do notice one of your example URLs has the trailing forward slash and one does not. How many WP installations are running in your "redrum" directory? – jdm2112 Jan 6 '15 at 14:24
  • I'm only running one installation of WordPress, and I was just testing a few things with the forward slash, at the moment I'm using absolute links but this isn't the best method I could use, for example: localhost/redrumwordpress/wordpress/1-5/redrum-10 instead I would like to use 1-5/redrum-10 as the link, however I can't get this to work on 3 of the links as it re-directs me to a different page. Edit: this website was originally made by a different person, who no longer works here, I was requested to convert the website to WordPress, but wordpress re-directs pages 10, 11 and 12. – Gerwin Jan 6 '15 at 14:32
  • No idea if this helps with your situation but we've had lots of trouble with relative URLs in WP. When developing locally or in a temporary environment, we use absolute URLs in content areas (page/post editor, widgets, etc) and then update these globally at launch. If this bit is in your template code or a function, you may be good using one of the WP path functions such as get_stylesheet_directory(), get_theme_root(), etc. codex.wordpress.org/Function_Reference/get_template_directory – jdm2112 Jan 6 '15 at 15:06
  • I'm confused how <a href="1-5/redrum-5/"> could ever link to 1-5/redrum-4 redirect or otherwise. I get it that this is a "next" button, but if the href is redrum-5 that's where it's going. WordPress isn't going to automagically guess that you want to go to the "previous" or "next" page. Perhaps you could clarify a bit more? – Tom Auger Jan 6 '15 at 21:26
  • Sorry, it linked to 1-5/redrum-5 which is correct, but when I link to the 10th page it doesn't go to the 10th page, it goes to the 'hub' of the pages for some reason, it may be the case that I have insufficient knowledge of the project to adept the website to work with WordPress because I wasn't the one who originally worked on said project. TL;DR: 1-5/redrum-10/ links to the hub of said page, instead of the page itself – Gerwin Jan 7 '15 at 9:23

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.