I have 3 problems. First,I would like something like this to do :
www.example.com/myblog => myblog.example.com
myblog is template page.
and then when open one post from that page(post are custom post type) url will look like this myblog.example.com/my-custom-post-type-post
Second :
www.example.com/mycar => mycar.example.com
my car is also template page,and then when open post from that page(posta are also custom post type,but this time post will be in subcategory) url will look something like this
mycar.example.com/my-subcategory/my-car-custom-post-type
Dont know how to do this in wp.
Third,can someone help me to figure it out why is this not working. I would like to rewrite this url http://www.example.com/data-page/?data_id=123456789 to http://www.example.com/data-page/data_id/123456789
add_filter('query_vars', 'add_my_var');
function add_my_var($public_query_vars) {
$public_query_vars[] = 'data_id';
return $public_query_vars;
}
function add_rewrite_rules($rules) {
$newrules['data-page/data_id/([0-9]{1,})/?$'] = 'index.php?data_id=$matches[1]';
$rules = $newrules + $rules;
return $rules;
}
function flushRules() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
add_filter('rewrite_rules_array', 'add_rewrite_rules');
add_filter('init', 'flushRules');
This is the way I send data to another page.
<a href="<?= add_query_arg(array('data_id'=>32),get_permalink(get_page_by_path('data-page'))); ?>">Data page test link</a>
Thanx in advance.