Just write a function that checks if permalinks are on by checking whether get_option( 'permalink_structure' ) is empty or false and generates the appropriate link given the $id.
Something along the lines of the get_permalink() function which either looks at the $post global or looks at the $id passed into it.
Related Posts:
- Why doesn’t flush_rewrite_rules run on plugin activation?
- Help With Rewrite_Rules For a Custom Plug-In
- rewrite URL based on selected taxonomy for post page
- Problem with dinamic add_rewrite_rule()
- add_rewrite_rule behaving strangely
- Add variables from rewrite rules to query var
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Best way to flush_rewrite_rules for custom post type, in a mu-plugins plugin?
- Custom frontend page for plugin without a ‘physical’ page?
- How to Rewrite WordPress URL for a Plugin
- permalinks with get variables
- WordPress plugin how to run function when button is clicked
- Plugin to Consume a Web Service
- Use an empty page to build custom plugin output
- External Rewrite Rules
- Add Post and Comments menu no longer visible
- Rewrite url for existing page without flush_rewrite_rules
- Does WP Have a Function To Generate .htaccess RewriteCond?
- Creating a path in a plugin to call a function
- URL rewriting must be activated manually for my plugin
- 404 errors after plugin options update and category base change
- How to restore WP 5.4 behaviour where a numeric string could added to each page URL and parsed as “page” in WP 5.5?
- How to change the URL pattern for single post view
- Custom url for a plugin page add_rewrite_rule WordPress
- Auto save permalink setting page with the plugin activation
- How To Consistently Enforce Rewrite Rule in Plugin Development
- Append varible to url or set session
- Adding rewrite rule dynamically
- How can I turn a custom wordpress page into a product page?
- WordPress Custom URL
- Remove custom post type slug from URL and add taxonomy Slug
- custom permalink’s rewrite rule for page id
- HowTo to add my rewrite rules at the beginning, redirect to the right page and flush the rules on plugin activation?
- How to grab query string from wp-content/uploads/.*
- Show content without a post
- How can I add rewrite rules to a class-based plugin?
- How to get post image root URL?
- How to create new content type and flushes rewrite rules without visiting the permalinks page?
- configuration of .htaccess for add_rewrite_rule to make sense
- Forward an old url rewrite scheme to a new one?
- Plugin architecture to pull from API & create dynamic content on WP site?
- Changing permalink structure breaks link to .php file which generates files dynamically
- wp_insert_post generated mixed permalinks
- Access to the template file of a plug-in
- Rewrite not working since upgrade to 5.9
- Custom post type change permalink query
- Home page is not loading, where in other pages are displaying on the site
- WordPress: I wanted to use Add rewrite rule multiple times for multiple CPT in my plugin
- WordPress Own Rewrite Rules
- Get the current post/page URL with plain permalinks
- Adding body class in author page for custom role
- Author Meta in Author URL Link
- WordPress plugin how to run function when button is clicked
- Using meta_key & meta_value in add_rewrite_rule
- Get (eventual) permalink from post within Edit Post in Admin panel
- Any way to make Apache’s internal redirect work?
- WordPress permalink setting
- How can I map a specific URL pattern to a plugin for processing
- Custom slug in url for CPT and taxonomy
- add_rewrite_rule not working
- How to Rewrite WordPress URL for a Plugin
- Virtual Page with Registration form
- Get URL of Post You Are Editing
- How to use permalink query to go to specific tabs in posts
- How to Rewrite WordPress URL for a Plugin
- URL rewrite parameter lost (add_rewrite_rule)
- Custom rewrite, url path with parameters to a page
- WordPress – Custom permalinks for advanced custom fields (ACF) using post type taxonomy
- How to add multiple custom URL variables?
- Problem creating cron job wordpress
- Hook event for upload image in the menu
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- What’s the better way to add an inline script?
- Adding JS function as third parameter in do_action
- How to assign a WP 3.0 custom nav menu to a theme’s navigation menu location via script?
- Order properties should not be accessed directly
- Where to store the name of a custom table?
- Rewrite Rule for default post type
- Backbone event attachment:compat:ready can’t hook
- Add a class to a dynamic sidebar’s wrapper
- Upgrade private plugin without deleting files?
- Issue with querying
- Detect front-end pages only in init hook
- best way to make a WordPresss multisite that is secure but at the same time supporting my plugin development efforts
- How to change title tag at page after loaded post?
- Creating Admin Plugin – Content of a page is displayed at global scope as well
- rest_no_route on custom API endpoint wordpress
- Additional classes `undefined` after saving post in Gutenberg
- How do you submit a Gutenberg plugin?
- WP nonce field checkbox prints checked=’checked’ outside input field
- Information and Page from WordPress Plugin
- Create new page in wordpress plugin which doesn’t exist
- Need Help to make a logic for editing posts in Frontend
- PHPUnit Testing and woocommerce Constant
- WordPress Query doesn’t return the correct value
- How to force download a plugin generated file?
- Upload images to custom database table in admin backend
- Adding admin for specific users
- Attach an image to new posts
- WordPress Plugin default option