Hi @signale,
When it comes to your first question, you are right. If you add is_single() as a third condition, the snippet will be active only on single post pages.
If you would like to change ?p=ID to ?post=ID, you need to replace this line:
$permalink = add_query_arg('p', $post->ID, $home_url);
with:
$permalink = add_query_arg('post', $post->ID, $home_url);
thanks, Maciej.
Technically it does the trick, but, mm, I mean, is it possible to have the post work on this url too, cause you see, when opening http://agency.smartleads.eu/?post=40 – it doesn’t see it.
I mean WordPress doesn’t know this “post” tag is equals to “p”
I am afraid that you will need a custom solution here. I am really sorry, but due to high number of custom development requests, I am not able to provide them here. Generally, this support forum is dedicated to issues related directly to Permalink Manager Lite.
Anyway, the easiest way to use ‘init’ action hook and set $_GET[‘p’] programmatically before WordPress starts to parse the posts query:
if(!empty($_GET['post']) && is_numeric($_GET['post'])) {
$_GET['p'] = (int) $_GET['post'];
}
Eternal gratitude to you. I’m aware of the help you gave me and, please, if you provide paid support – I will be more then happy to send you the payment.
Just correct me please if I’m wrong as I’m not a coder and only a designer, so I’m doing it intuitively
I’ve translated this part
the easiest way to use ‘init’ action hook
into this code:
add_action('init', 'set_new_tag');
function set_new_tag(){
if(!empty($_GET['post']) && is_numeric($_GET['post'])) {
$_GET['p'] = (int) $_GET['post'];
}
}
but I’m afraid this part
before WordPress starts to parse the posts query
is not totally clear to me. I’ve inserted it into the beginning of the functions.php and it works great, though if I missed some condition checking, will be great full to know which. Sorry to bother, I’m sure you got enough orders with such brilliant knowledge, just please have mercy 🙂
Hi @signale,
your code is absolutely correct, “init” is triggered before “parse_query” hook 🙂
https://codex.ww.wp.xz.cn/Plugin_API/Action_Reference
Best regards,
Maciej