Support » Fixing WordPress » Linking to pages in root folder

  • So my site’s architecture is as follows:

    Root folder
    – index.php
    – about.php
    – contact.php
    – etc.php
    – images/
    – stylesheets
    – blog/ (folder where wordpress is installed)

    Within my wordpress template.. I’ve created my custom single.php page to style whenever a user queries just a single post. However, my blog’s structure is running so the navigational links go back to the main root folder to where my static pages are. So in my blog’s index.php file.. my navigation is linked to ../../contact.php to go back to the root. However, when a user tries to navigate from a single post page using the single.php template.. the path doesn’t work.

    Is there code that I can use to link back to the root folder OUTSIDE of the blog’s root folder besides just putting all my pages in the blog’s root directory itself?

    Sorry if the post is hard to understand.. please let me know if I can clarify it a bit.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Use only absolute links (the ones with http://).

    Also, consider using the very useful bloginfo in your WordPress template files:


    I’m currently using bloginfo() for linking stylesheets and images WITHIN the WordPress folder. I may have overlooked it but can bloginfo assist me in linking to files outside of WP’s root folder?

    For links outside of WordPress, just code absolute links into your theme or add them to your blogroll bookmarks in their own category and then use wp_list_bookmarks to display just that category in your theme files.

    Maybe using something like this may work:

    <base href=”” />

    If I did decide to keep everything, including my blog, in my root directory.. what would be my desired path to link to static pages within the same directory? I was assuming that if I had my navigation in my header.php file.. and I wanted to link to my contact.php, I would just do a href=”contact.php”.. However, that path would be incorrect since it would link to my root folder and not to the template location where my theme and static pages are.

    For example..

    /root directory/
    – index.php (WordPress)
    – header.php (WordPress)
    – sidebar.php (WordPress)
    – footer.php (WordPress)
    – contact.php (static)

    Because of its dynamic nature and variety of different content paths (post, page, index, category, tag, archive, etc.), within WordPress, you need to use absolute links, not document relative ones.

    This page has info on absolute links:

    I’m looking to do the same thing airporte is. I guess I’ll stick to absolute links but would love to know if someone came up with how to use a line of php to look one (or whatever user set number) folder above the WordPress folder. You would use it in the same way as bloginfo.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Linking to pages in root folder’ is closed to new replies.