There might be other ways, but what I would so is create a rewrite rule in your .htaccess file, something like:
RewriteRule ^items/([0-9]*) /items/?page=$1
Now your user sees:
http://mywordpress_site.com/items/1/
But behind the scenes, your site sees:
http://mywordpress_site.com/items/?page=1
Then in your shortcode:
$page = (int) $_GET['page'];
WP has tools in it to manage rewrites, and it would probably be better to use those instead of .htaccess, so you can keep all your code contained in your plugin folder. I haven’t played with that yet, so here goes nothing:
This SHOULD do the same thing, but without modifying the .htaccess file.
add_action( 'init', 'add_items_rules' );
function add_items_rules() {
add_rewrite_rule(
"items/(\d*)",
"items/?page=$matches[1]",
"top"
);
}
Related Posts:
- How to force load a page in plugin?
- Custom pages with plugin
- Pass PHP variable to javascript
- Is there a way (plugin?) to restrict a user to being able to edit just one page?
- Creating a WordPress admin page without a menu for a plugin
- What is the best page ordering plugin that works well with WPML? [closed]
- Add rewrite rule to permalink structure
- Add Rewrite Rule for custom page
- Best way to manage a lot of pages in Wp Admin [closed]
- add_rewrite_rule, plugin activation and plugin deactivation
- Create page when plugin is activated
- jQuery plugin only in one page/post
- What is the best way to output plugin result in certain url
- Changing page URL and connect newsletter to MailChip
- WordPress page and plugin list using sql query
- Create page from plugin, but have it completely hidden
- How to Create a Custom Slug for Tags and Categories with a prefix or suffix?
- How to add subcategories to the blogroll?
- URL rewrite of independent plugin?
- Plugin generated taxonomies’ permalinks with custom placeholders
- How do I write an inventory list plugin that creates dynamic details pages?
- Can I allow certain people to add/edit pages within a parent?
- Proper way to replace the_content only for pages created by custom plugin
- Add menu page issues (permissions & position)
- Display Custom Field Value on Admin Page Column
- Would Gutenberg be considered a PlugIn?
- I need help locating a URL that is on my site map, but that I can’t find in my WordPress dashboard
- Show author on every sub-page
- How to have sample page for each new register users in a membership website
- One sub site is slow while all others load fine, same theme & plugins [closed]
- Locked out of admin panel after installing HC Custom WP-Admin URL [closed]
- Edit Permalink Structure For Custom Post Type or Modify .htaccess?
- How to create a page with links to other pages that include image and excerpt?
- Custom url rewriting
- How to customize a title by passing query string?
- Thesis 2 custom Page
- WordPress plugin url for form submit
- Making my plugin create a page?
- Creating author Specific page URL
- Add Content to Content()
- Simulating a wp page – wp page load sequence
- URL rewrite with external JSON query
- How to create wordpress page that lets users create their own quiz? [closed]
- Huge number of 404 pages getting spawned
- Username Variable in custom links?
- Get post content from outside the loop with plugin shortcode usability
- WordPress rewrite rules not working
- How to rewrite URL and get the values?
- How to create plugin auto create page wordpress?
- Do rewrites added with add_rewrite_rule() persist after plugin deletion?
- Custom form not showing in correct place on page
- Change website directory safely to add a static page on startup
- Price comparison table based on Custom Post Type?
- Use jQuery Datepicker code from plugin
- How to dynamically change spots of text in custom page?
- How to embed a new string in url?
- Custom page in plugin visible in menu
- i want to rewrite my custom plugin url
- rewrite file to wordpress
- Adding a pagenavi to function for displaying bookmarks
- Is there a syntax highlighting plugin for HTML View? [duplicate]
- What is the best way to make a custom page from a plugin?
- Setting text widget to one page only
- Pasting this PHP breaks my page. Why?
- Modify pages widget and make a plugin?
- How do I create pages within a WordPress post?
- Gantry Framework: new page loads homepage content instead of page content
- Woocommerce checkout page broken when set as a checkout in woocommerce settings [closed]
- Elementor Combined all Sections into 1 Text Editor
- Custom plugin places html head content in body
- TranslatePress | secondary language category/sub-category not working correctly “`/%category%/%postname%/“`
- Pass PHP variable to javascript
- Dynamic URL Rewrite for Custom
- How to permanently show Word Counter on Create/Edit Page. WordPress5.9.3
- Displaying page content from plugin, inside exising empty WP page
- Oops! That page can’t be found
- Change language on website and change currency with url query
- Copy/paste local images not working in WordPress
- Use get_pages() before another plugin modifies it
- how to show all posts of each category in pages
- add_rewrite_rule to load different page, without changing URL in browser
- Elementor: How to design Dropdown Select Box Navigation page like Chegg
- Give custom page template a custom post ID
- Bookmarking custom template pages which all have the same page ID
- Hidden permalink different from displayed permalink
- create pages automatically and dynamically in wordPress
- Adding LOAD MORE on a page
- Randomize post (and page) IDs on generation
- Having a problem with rewrite_rules and rewrite_tags – url not rewriting properly and query var missing
- WordPress Frontend Page using Plugin
- WordPress rewrite rule depend on meta values not ids
- Custom Rewrite Rule Removing Query String
- one url for all pages
- What plugin would make this happen? If is the theme
- Automatic chage password of pages after some time
- Powerpress upload a podcast without creating a post for it
- How to allow URL with filename & extension in wordpress?
- Allow a page to be edited by a specific custom role
- How to Disable Auto Executing Script in A Particular Page Only
- How To Use htaccess to Rewrite Link Structure for a Page that is Generated Programatcially