$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)
- How does WordPress create URLs that Apache knows about?
- Stop WordPress appending `-2` to the end of my url after i change it
- Get current URL (permalink) without /page/{pagenum}/
- How to get pretty URLs with add_query_arg in permalinks
- Creating custom permalink structure for languages
- Adding another word in front of post url
- Update URL Snippet to Canonical Permalink URL
- why does anchor name add a slash to url?
- “.#[random-char-string]” being inserted at end of URLs
- How to create a permalink structure for posts in a specific category
- How to Remove Slug From Database?
- How to make draft posts or posts in review accessible via full url / slug?
- Social Media Links on homepage – within posts/post loop
- 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
- Redirect user if it’s not logged in
- How to Modify Existing Rewrite Rules?
- Using ‘Primary Category’ in URL
- Can two products with the same name but different category produce unique URLs?
- I copied my site to another site but all links point to old site
- Get closest page ID from URL
- How to reset canonical URLs / fix redirect loop
- How to show the homepage on a different url, like site.com/blog instead of site.com?
- wordpress api using rest_route for other pages
- Automatically append ID to at the end of specific URLs
- Force wordpress to display page with same url structure as categories
- How can i have a custom post type with more slugs for each post?
- How to change old permalink?
- URL rewriting: removing the site’s basename for a specific category
- Migrated from Windows to Linux. Any bulk methods for fixing case sensitivity?
- Host frontpage via example.com and everything else via example.com/blog
- WordPress can generate numeric permalinks, which then 404
- display dynamic content based on url slug on custom page
- Pre-populate Slug / Permalink with URL
- How to use all tags in post permalinks
- Unique one time use URL
- Can WP give a value a post ID?
- Remove parent page from url
- Problem with parent page slug only in WordPress admin
- Getting back a permalink from custom url
- “-2” Being added to end of URL (no duplicate pages, no pages in trash)
- 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
- Remove international characters from slug – Almost done – Bit help
- Post with no tag permalink problem
- How to make different urls for some tags pages
- replicate url permalink after migrating to wordpress
- How to remove slug from front page?
- 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”
- Can I link to content dynamically from a page to a new page?
- Propper way to set anchor and url param
- Remove link function from oembed image or video
- Get value from URL with different types of parameters
- a way to support totally different url structure
- 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?
- How to change dynamic link to relevant post
- Imported posts using wrong domain name
- Possible to hide parts of the slug from get_template_directory_uri and bloginfo(‘template_directory’)
- Latin character conversion
- Using a taxonomy value as part of a post URL
- Permalink structure as code in back-end?
- Are custom page templates being used to get this permalink structure
- Change permalink in wp-property
- Include language variable in url
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- WordPress keep redirecting me to random URLs
- Make all internal links relative, or otherwise make a website accessible from multiple domains
- Remove parent product category slug from product_cat url woocommerce
- Change default URL (or permalinks) in the back-end
- how to ensure url uses post_name and not query post id?
- Duplicate Content Issue with WordPress Permalink Structure and Primary Categories
- Get Page URl when changing slug and permalink
- Can’t Remove Unnecessary Slug
- WordPress homepage shows default theme after migration – logged-out users see different content