I’ve created a rewrite do redirect like:
/mylisting/909 ->/wp-content/themes/myplugin/edit.php?id=909
Which seems to make sense as I’m keeping the very specific logic to an individual plugin.
There is a better way: Create an endpoint, use your code in a callback handler for the new URL. You get the whole theme environment for free here: get_header()
, sidebars, menus etc.
Do not forget to call exit;
at the end of your endpoint, othrwise WordPress will use the theme files again. 🙂
The plugin URI is never a good address to edit or create content: It might be on another domain where the cookies are available, and no user is ever logged in.
Related Posts:
- How can I use WordPress functions in my stylesheet?
- How to check if a theme is active?
- how to get path to images in the uploads folder to be used in a plugin
- How to maintain W3C standards compliance of a theme
- Difference between a theme and a plugin?
- How can I have two different urls for the same page that load two different templates?
- All shortcodes not working on custom theme
- How to enable edit button in the theme’s customize UI?
- Disable plugins on cron and ajax page
- Is it good practice to remove redundant plugins and themes?
- Ship plugin with a custom theme
- Declare a function before plugin does on the theme functions.php file
- WordPress error – PHP Fatal error: Uncaught Error: Call to undefined function register_block_type_from_metadata()
- Whats the difference between Page Builder Plugins and Theme Builder Softwares? [closed]
- How to use load_plugin_textdomain from within a theme
- Theme and Plugins sharing common libraries
- Workflow and best practice for documentation [closed]
- Is there a quick way to inject i18n domain into theme/plugin files?
- How to avoid redefining requirejs in plugin when another plugin also uses requirejs
- Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory
- Can I share predefined fonts from theme_support with a gutenberg component?
- Is there a reliable way to keep track of how long a WordPress theme has been active?
- add_action in functions.php, do_action in plugin?
- Implement plugins as part of a theme
- How can I list recent posts excerpts?
- Theme or Plugin: Where should I write my code?
- Plugin Deactivate Self on Activation Errors
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Do I still need a theme to use page builders?
- Two (or more) looks, with one set of content
- Can I make a super plugin that also has a theme?
- Prevent WordPress installing plugins and themes via Admin
- Plugin Handle URL With Custom Theme
- How to read individual user’s directory and display content to that specific user?
- WSOD after upgrading to 3.1
- Check for security updates
- Is there any kind of theme on WordPress to sell my own movies?
- All sites themes functions.php have been changed
- Is there any hook for theme activation ? or something similar?
- “No Add Button” for me to customize my WordPress with themes and pluggins
- How can I list all installed plugins/themes/versions from CLI/API?
- Is there a way to get plugins and themes not built for multisite to work on a network subsite?
- Why does my file_exist check fail?
- How to protect WordPress from security scanner [closed]
- how can I query all wordpress users of a blog
- how can I do something on new user registration?
- Making that Admin Bar transparent or a blue color
- how to activate a plugin inside a theme
- There has been a critical error on your website – won’t fix no matter what
- Is it possible not to load theme on a specific page in wordpress?
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- I receive taxonomy id
- To perform the requested action, WordPress needs to access your web > server
- How to extract a .wp-env.json or composer.json containing plugin versions from a production website?
- How to include files relative to a file’s directory
- Override css rules of a plugin within my own theme
- I want to use wordpress themes and plugin to develop website
- Blocking Plugin Css to load custom in template directory
- WP e-Commerce Gold Cart with Plugin Built Into Theme
- After a manual update, themes and plugins that were installed (and still in the directory) are not being seen
- Display WordPress comments before the plugins?
- Mobilepress fails to translate short codes
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Edit all $wp_scripts at once to $in_footer = false
- In Multisite Setups, how to update mass sections of sub-sites
- How to override any plugin file in the child theme
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Mobile Menu and Mobile Sidebar missing
- custom fields not displaying on wordpress site
- elementor development – custom widget like an inner section widget
- Different theme menu
- Bash script to check available updates
- WordPress fresh installation did not update default plugin and themes to latest version
- How to store a custom theme and update it on other installations
- How to get a post views count using ‘WordPress popular posts’ plugin
- Can’t add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS
- How to prevent redoing get_posts queries and make results available to other scripts?
- Is it possible to disable a theme programmatically?
- Google trying to index child theme files
- Cron job emails blank
- In the WordPress API is there a way to set the width of the post/page container
- How can I add a custom checkbox / radio button on the admin theme options to display a CSS or other?
- What Are the Advantages of Using an mu-plugin
- How to fix On “An unexpected error occurred” message when I click on Add new theme or plugin?
- How to display post by date written (1974) and not date published (today)?
- Things that saved lose when logout
- Child Theme Changes Are Not Reflecting In Parent Theme
- Automatic updates of plugins and themes outside of wordpress.org
- Theme specific plugin, how?
- Run WP inside a other Site without using frames
- Breadcrumb is not generating the correct post page url
- Display static pages instead of category, in code
- Theme causing SSL break on chrome
- Why does theme need woocommerce to show images / content on front page?
- Install theme as part of a plugin
- Divi Template A Few Questions
- Trying to use wp_register_script/style and enqueu them from an array – getting an error [duplicate]
- My Blog page ( posts page ) theme isn’t changing with the new theme [closed]
- Issue with customizer and widget page
- WordPress menu dissapear when I add a parameter to custom post archive