You’re probably getting that error because WordPress doesn’t have the $wp_rewrite global loaded yet for some reason. Either something deactivated it, or you’re trying to run those functions before WordPress has a chance to load it.
If you’re trying to do this in a plugin or in your theme’s functions.php file, make sure you’re inside a function that is hooked to after_setup_theme or a hook that runs sometime after. For example:
function get_url_of_page_id_165() {
return get_permalink( 165 );
}
add_action( 'after_setup_theme', 'get_url_of_page_id_165' );
Related Posts:
- How can I store page ID in a post instead of other selected permalink?
- Get the url of a page template without using the page slug and ID
- Edit permalink for certain pages
- cannot link a external url, present page url acting as parent url
- How to use page jumps to top of banner and page title?
- How can I see a list of all pages my WordPress site has generated?
- My WP homepage works, but the other pages don’t when accessing from out side of my network
- Can I link to content dynamically from a page to a new page?
- Is it possible to get a page link from its slug?
- How can I reverse engineer a Permalink to Find the Page?
- How to use relative links on my pages?
- Removing hierarchical pages in the permalink
- Can WordPress realistically handle a site with 500 ‘pages’?
- Passing variables through permalink structure
- Broken wordpress permalinks on pages only
- How to Remove Slug From Database?
- Why does WP not use relative links when linking pages?
- Menu Link Redirect Based on Username or User ID
- Social Media Links on homepage – within posts/post loop
- Relative or Absolute Paths for Flash Video Player Files
- Should I use relative or absolute urls when pointing to internal pages
- How to change the permalink structure of a master page?
- Why I can’t change the permalink of this page?
- Page Attachment Permalink Structure based on Menu Order?
- I copied my site to another site but all links point to old site
- Best way to add internal link in widget
- Get closest page ID from URL
- How can I add a page’s ID to its permalink using WP_Rewrite?
- Permalinks for pages
- Permalinks by page/post name returning 404
- Automatically append ID to at the end of specific URLs
- why some permalinks adding characters/ruining links
- Pages not using permalink
- Is it possible for a custom post type and sub pages of a page with the same slug as the custom post type to share a slug?
- Add prefix to page URL based on the page template
- How to change old permalink?
- Migrated from Windows to Linux. Any bulk methods for fixing case sensitivity?
- How to eliminate permalink prefix in WordPress Multisite
- Remove -2 from URL; no duplicate pages, no images, no pages in trash
- How to handle broken links created by permalink/slug changes?
- How to generate a list of all urls
- WordPress is suppressing page extensions!
- Let me choose permalinks
- Passing the JQuery string to Worldpress URL
- Path to Pages Resolves to Archive instead of Actual Content
- Changing permalink name redirects to another template?
- Permalink opens attachment instead of page
- How do I reclaim either deleted pages or their permalinks?
- Format HTTP links
- Permalink of a page that has already been deleted
- Can WP give a value a post ID?
- Test site pages go to main site
- how to get a list of all top level pages
- Redirect From Url To Url
- Moved site, Old links in pages still pointing to old host
- How are WordPress Page URLs affected by permalink settings?
- Get a link to paged() part?
- WordPress Page Not Found if Permalink Settings is Postname
- Pagination url for page template
- Why does enabling Permalinks make pages not found?
- Create custom links for excerpts with php dynamically
- Page content doesn’t display when published but does when previewed as draft?
- Update page breaks permalinks
- How to link post titles on page A to its posts on page B?
- WP as a CMS menu
- Subdomains pointing to a permalink URL
- Default Permalink Structure for Pages
- Non Latin page permalink problem
- How to make different urls for some tags pages
- How do I structure my permalinks in WordPress?
- A dash can replace a period in a link, how to fix it
- Nested permalink without dummy parent page
- Custom Permalink (with category) for Pages
- Propper way to set anchor and url param
- Find internal links to post
- rebuilding/ rewriting a url to make it SEO friendly
- Remove link function from oembed image or video
- Page returns 404 for specific permalink
- Change all pages permalinks instead of hierarchical to have id of the page
- The permalink for the page doesn’t work and page’s defined link throws “Object not found!”
- How to change dynamic link to relevant post
- Difference and usage of uri (e.g. get_directory_uri) and absolute path (e.g. get_directory)
- Page permalink ending in “-2”
- Change the permalinks structure
- Development before domain name chosen
- 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
- Select page/template from the permalink url
- Latin character conversion
- Permalink for pages
- Pretty links for PHP pages above WP /blog directory?
- Permalink / sub-template issue
- Permalink structure as code in back-end?
- Mystery ghost page not appearing in Admin
- Category pagination first link works, remaining don’t
- What is the issue with our links? It creates a loop
- wp_get_attachment_url not working
- Permalinks of New Pages and their Parents
- Why doesn’t my page know it’s a page (won’t return true for is_page())?
- Make all internal links relative, or otherwise make a website accessible from multiple domains