WordPress.org

Ready to get started?Download WordPress

Forums

Linking to pages in root folder (9 posts)

  1. airporte
    Member
    Posted 5 years ago #

    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.

  2. iridiax
    Member
    Posted 5 years ago #

    Use only absolute links (the ones with http://).

  3. iridiax
    Member
    Posted 5 years ago #

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

    http://codex.wordpress.org/Bloginfo

  4. airporte
    Member
    Posted 5 years ago #

    @iradiax

    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?

  5. iridiax
    Member
    Posted 5 years ago #

    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.

  6. hunink89
    Member
    Posted 5 years ago #

    Maybe using something like this may work:

    <head>
    <base href="http://www.yourwebsite.com/root" />

  7. airporte
    Member
    Posted 5 years ago #

    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)

  8. iridiax
    Member
    Posted 5 years ago #

    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:

    http://codex.wordpress.org/Linking_Posts_Pages_and_Categories

  9. nosleephotel
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic