$my_url="my/relative/url.php";
echo site_url($my_url);
site_url() when used by itself will return the absolute path to your blog. But, if you add an argument to it, as per my example above, it will prepend the absolute path to your path. Just make sure your URL doesn’t contain a leading slash (eg: /this/may/not/work).
Finally, if you happen to have your wordpress installed in your server’s root, you can use a server-relative path (this uses the leading slash to indicate starting at the server root). So if your blog is installed at http://www.me.com/blog
then you can access your relative links safely with /blog/my_link.php
.
Related Posts:
- Change website URL without breaking links or images? WP 3.3
- Confusion about how a URL is being parsed
- Get the url of a page template without using the page slug and ID
- How to generate a list of all urls
- Edit permalink for certain pages
- cannot link a external url, present page url acting as parent url
- rebuilding/ rewriting a url to make it SEO friendly
- Difference and usage of uri (e.g. get_directory_uri) and absolute path (e.g. get_directory)
- remove “index.php” from permalinks
- How does WordPress create URLs that Apache knows about?
- Stop WordPress appending `-2` to the end of my url after i change it
- Get default permalink structure from pretty URL’s
- Creating custom permalink structure for languages
- Getting the Site URL Including the Front Base
- Adding another word in front of post url
- Removing hierarchical pages in the permalink
- How to Remove Slug From Database?
- How to make draft posts or posts in review accessible via full url / slug?
- Remove subfolders from URL
- Why does WP not use relative links when linking pages?
- Social Media Links on homepage – within posts/post loop
- flexible rewrite ‘ramble’ URLs with WordPress
- How to increase the character limit for post name of 200?
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- WordPress 3.4 Permalinks Redirection Problem
- Make attachment pages require a base url
- How to Remove -14 from WordPress URL (Permalink)
- How to Modify Existing Rewrite Rules?
- display URL or permalink instead of page title in dashboard
- Change permalink rule if category is called “uncategorized”
- Can two products with the same name but different category produce unique URLs?
- Get canonical link
- Best way to add internal link in widget
- Get closest page ID from URL
- How to reset canonical URLs / fix redirect loop
- CSS not loaded when omitting www. part of URL
- Setting up two separate blogs while using WordPress as a CMS
- How to show the homepage on a different url, like site.com/blog instead of site.com?
- Automatically append ID to at the end of specific URLs
- Non latin post slug truncate
- Is there a link parameter that will show me all my published pages?
- How to change old permalink?
- How to eliminate permalink prefix in WordPress Multisite
- Remove -2 from URL; no duplicate pages, no images, no pages in trash
- WordPress keeps giving me the wrong permalink
- display dynamic content based on url slug on custom page
- Relative v.s. absolute URLs: which ones should I use for cross-domain portability?
- Format HTTP links
- Unique one time use URL
- Can WP give a value a post ID?
- Getting back a permalink from custom url
- Bulk append URL (add word to slug)
- Moved site, Old links in pages still pointing to old host
- How to use page jumps to top of banner and page title?
- replacing post ID by custom post name in url
- Access posts while mod_rewrite is broken
- How can I see a list of all pages my WordPress site has generated?
- Remove international characters from slug – Almost done – Bit help
- How to make different urls for some tags pages
- replicate url permalink after migrating to wordpress
- Can I change the URL structure for a CPT only?
- How to remove slug from front page?
- How to redirect old permalinks from https://exmaple.com/category/post_id to https://exmaple.com/category/post_id.html
- Make a post inaccessible without a unique ID in the URL
- A dash can replace a period in a link, how to fix it
- assets aren’t loading on a page but loads on others? slug permalink conflict?
- Multiple Taxonomy Items for Separate URLs
- WordPress keeps removing query var from the URL
- URL gives 404 error of my subfolder site when i change permalink
- Change Project permalink to custom URL
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Using a template file for a specific custom URL
- Nested permalink without dummy parent page
- Extra url paths as variable
- Passing parameter through permalink structure
- Custom Taxonomy rewrite rule causes 404 error on page or single post depending on if it’s set to “True” or “False”
- Post links broken after migration
- Can I link to content dynamically from a page to a new page?
- Added a prefix in URL permalink structure but the old structure still working!
- Find internal links to post
- Remove link function from oembed image or video
- add bar in paging in the URL
- WordPress Page URL
- Remove/hide a specify category-name from the url
- How to change URL of my pages?
- Imported posts using wrong domain name
- Possible to hide parts of the slug from get_template_directory_uri and bloginfo(‘template_directory’)
- After changing permalink settings, everything works fine except for the two most recent posts
- How to display post permalinks instead of pages?
- Using a taxonomy value as part of a post URL
- Why is there a # and other characters in URL for WordPress site?
- Permalink structure as code in back-end?
- wp_get_attachment_url not working
- How to avoid duplicate Url for the home page
- Are custom page templates being used to get this permalink structure
- Include language variable in url
- Removing parent page in URL for one page
- Make all internal links relative, or otherwise make a website accessible from multiple domains
- Remove parent product category slug from product_cat url woocommerce
- Standard Htaccess directives disappear by themselves