WordPress.org

Ready to get started?Download WordPress

Forums

Relative Linking (2 posts)

  1. quaziblue
    Member
    Posted 3 years ago #

    I'm using the Widget Block plugin so I can create widgets that only display on specified pages.

    What I'm finding is that it seems impossible to include a link to a page in the widget because it won't work if it's on a sub-page.

    For example, in the widget block, I'm linking to my contact page (http://localhost/website/contact) by using <a href="../contact">contact</a>.

    On a main level page (e.g. http://localhost/website/about), it works perfectly by directing me to: http://localhost/website/contact.

    But on a sub-page/child page (e.g. http://localhost/website/about/subPage), it directs me to: http://localhost/website/about/contact.

    Is there a way to use relative addressing so that I can link to my contact page no matter which page the widget is located on? I know absolute addressing is an option, but replacing all of those links when I go live is a pain (even with the Search & Replace plugin).

    Any help would be appreciated.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    You cannot use relative urls in WordPress without experiencing unpredictable results. Stick to full, absolute, urls.

Topic Closed

This topic has been closed to new replies.

About this Topic