If BigOffer
part is static it can be easyly done with a rewrite rule:
add_action('init', 'big_offer_rule');
function big_offer_rule() {
add_rewrite_rule('^BigOffer([0-9]+)/?','index.php?pagename=bigoffer&offerId=$matches[1]','top');
}
add_filter('query_vars', 'big_offer_vars');
function big_offer_vars( $vars ) {
return array_merge($vars, array('offerId') );
}
After you added this code, you have to flush rules going in Settings -> Permalinks section in your backend and saving changes.
After that, you have to create a page with the slug: 'bigoffer'
. This page will be opened when you type an url like http://example.com/BigOffer12345
and the numeric part can be used looking at get_query_var('offerId')
, something like:
add_action('template_redirect', 'big_offer_id');
function big_offer_id() {
if ( is_page('bigoffer') ) {
// do something... following is just an example
// the function get_the_content_somewhere_by_id does not exist,
// just imagine is a function that retrieve the page content using the id
$offerid = get_query_var('offerId');
global $offer_content;
$offer_content = get_the_content_somewhere_by_id($offerid);
}
}
I’ve used the hook 'template_redirect'
so everything you do in the function is done before the page is displayed. Then I used a global variable to store the content retrieved, in this way in the page template you can just global $offer_content; echo $offer_content;
.
Off course is not real code is just a proof of concept.
All this code, can be wrote in a custom plugin (suggested place), or in the functions.php
of the current theme.