catch urls with specific pattern and show specific content for them by plugin

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"
);
}