The reason that it’s an issue is because I’m using switch_to_blog() on a multisite. The post_type doesn’t exist on the current blog. It exists only on the main blog. Since the post_type doesn’t exist, the get_post_type_object() function is returning null.
What I did to fix this is create a custom_get_post_permalink function that also takes a blog_id argument and therefore changes to the appropriate blog_id on the multisite to create the post_type_object correctly.
Related Posts:
- where is permalink info stored in database?
- How can I reverse engineer a Permalink to Find the Page?
- Mapping Domains to Permalinks (not multisite)
- How to remove dates from existing permalinks?
- WordPress Permalink changes to question mark (?) in URL
- How would I create a different permalink structure for pages and posts?
- My permalinks are broken! Can I use mod_rewrite to ignore a physical file?
- Can WordPress realistically handle a site with 500 ‘pages’?
- How to prevent the default home rewrite to a static page
- Is there an action for when permalinks are rebuilt?
- When creating a WordPress page, a “-2” suffix is added to new pages’ permalinks
- mod_rewrite enabled but Permalinks show index.php
- How to get url of a post from admin panel
- How to get a page url by a page id?
- CPT archive 404ing when using a custom taxonomy name as a variable
- How to change “permalink” structure in “WordPress Thesis” theme?
- Performance and styles not working fine after changing permalink structure
- Turn off %postname% auto-incrementing?
- Maintaining two permalink structures
- removing index.php IIS 7.5 webconfig
- Custom Taxonomy URL
- Permalinks Messed up
- rewrite_rule for custom post type doesn’t affect get_permalink
- Add ‘articles’ prefix before blog posts url without affecting pagination
- Incorrect 404 for pages when using permalink, a static front page, and posts page
- Is there a wordpress function that I can use to retrieve the current page that is loaded?
- Custom Permalinks don’t work on local LAMP installation
- Problems redirecting to “pretty” permalinks (wordpress in Subdirectory)
- .htaccess file missing from WordPress install directory
- Remove permalink settings in post for users
- Remove multisite “blog” slug from specific custom post type
- WordPress Permalinks still not working despite all necessary settings
- RewriteRule accepts numbers but not letters in tag
- Server Move: All pages leading home
- WordPress Permalink 404
- Link to the post displays ID instead of slug
- Avoid WordPress categorizing a permalink request as Not found 404 Page
- Pages not using permalink
- Include Post Format in permalink
- Redirects after permalink change
- Why I can’t change the permalink of a WP page?
- Page preview is shown, updating page gives 404 error
- remove product-category base but still redirect to page with same permalink
- Process all virtual sub pages on parent page
- Correct permalinks and 404-error
- What would cause a theme to add extra characters to blog post links?
- Getting 404 when Access post which name start with Digit
- Custom permalink with two parameters
- How to check if the current page is the permalink page?
- Some Pemalink problems, probably caused by wrong .htaccess configuration?
- Permalinks set to /%postname%/ but still have links being indexed in the form ?p=x
- Custom links in menus not working in multiple environments
- 404 permalink errors on Pages only
- What happens to the permalink that use %postname% if I change the post name
- Issues when changing permalink Structure
- Assigning proper permalink to blog that is part of a website
- What would cause a 500 Server Error with permalinks turned OFF?
- Changing permalinks back to default ( ?p=123 )
- permalinks on title tag
- Non Latin page permalink problem
- How to redirect old permalinks from https://exmaple.com/category/post_id to https://exmaple.com/category/post_id.html
- Double Slash After Media Path (uploads//)
- New posts link to old posts (random)
- Custom permalink structure for product
- Is it possible to set public to false for the native WordPress blog
- Custom Permalink (with category) for Pages
- 301 redirects after changing permalinks
- Post links broken after migration
- How to change permalink for listings
- WordPress Pages that use Domain URL
- Link works although page was moved to another location
- wordpress admin panel loop on nginx
- Can’t access new WP install on subdirectory
- WordPress Permalinks
- WordPress All pages but home simply read “hello”
- How to change link of an uploaded file to the media library
- On Macbook, my permalinks with post name don’t work. Returning 404 error
- WordPress pages break with custom permalink settings (theme directory not output)
- Remove /index.php from Permalink
- Difference and usage of uri (e.g. get_directory_uri) and absolute path (e.g. get_directory)
- Fresh wordpress installation in sub-directory not accessible
- Get link from wpe_excerpt “read more” and move it
- WordPress 4.0 beta – how to change the link URL in RSS feeds
- Folder Name and Category Name WordPress
- How to display post permalinks instead of pages?
- Why is there a # and other characters in URL for WordPress site?
- Search points to /search/?s=KEYWORD instead of /search/KEYWORD
- How to change pagination base from slash to query form?
- WP Custom Permalink Filter
- standard post with extra parameter brings permalink problem
- redirect old pages by .htaccess
- wp_get_attachment_url not working
- Siteurl code for links
- Redirect Loops Problems
- WordPress Permalinks 404 Not Found
- WordPress 6.1.1 UTF8 Slug Limit Increase
- 301 Redirect posts to newly added categories
- How to have category/subcategory/posttitle/ permalinks?
- Website appears with wrong permalink in Google’s search
- Permalink settings are stuck on https, will not update to http