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
- dbDelta not creating tables
- How to implement color picker from wordpress in my plugin?
- Nonces can be reused multiple times? Bug / Security issue?
- Displaying search results in the widget itself?
- Missing “category_children” option when dynamically creating categories via a plugin
- Looking for callback function after Gutenberg is rendered?
- Date archive permalink modification
- How to duplicate a curl XML request using HTTP API?
- Widget Admin – Form Submit Event?
- WordPress security issue to output data from user input from theme option form
- how do you prevent showing a particular category on the admin dashboard for specific user roles?
- how query string in wordpress receive the value other than post and page [duplicate]
- Is there no admin ui guide for 4.x?
- Is there an event or an other method that tells me the preview is loaded?
- Widget Dropdown doesn’t working
- mysql_real_escape_string() vs. esc_sql() in WordPress
- Plugin AJAX Save to Custom Table
- How To Update WordPress Custom Plugin For Customer? [closed]
- How to insert HTML/CSS/JS into my iframe plugin?
- How to close tinymce inline popup
- Why doesn’t update_post_meta work for certain strings?
- Multiple dynamic Tax Query – pass taxonomy argument from array
- ajax stopped working when not logged in wordpress
- Overriding the template files using a plugin for all themes
- implementing socket.io with wordpress
- Determine if the current page, is being edited
- List Table action argument not cleared
- How to limit the number of posts a user can view based on status
- Error when trying to save custom post type settings (ERROR: options page not found)
- Is the only way to add taxonomy terms via an admin panel?
- Fetch Custom Woocomerce filed data and check the data avialble in Wp-user table as nicname or username using function.php
- How to get locale within WP REST Request?
- How to add extra EXIF data when images are uploaded?