I don’t understand your attempt to use PHP_Exec, especially by embedding it in the content section of the page. That is going to run much too late to alter anything in the <head>
of the document. Here is the problem you are facing, starting from what looks to be your primary question:
So what I need to do is understanding how WordPress is adding both the
meta in the final HTML. Is this something related to the
add_action(‘wp_head’, … something here)?
WordPress doesn’t add the meta
tags to the <head>
of your document, at least not most of them. It does add a few things– the admin bar stylesheet, meta generator, some feed stuff– but not the title, not the description, not most of the meaty bits. Your theme does that, and may or may not do it in a way that you can manipulate easily. Ideally, you can use a few different hooks– wp_head
, the_title
, couple of others maybe– to add and subtract content to/from the <head>
part of the document but some themes do not make it that easy. Sometimes things are hard coded into the theme.
Assuming everything is in your favor you can alter the title with:
function alter_title_wpse_82196($title) {
global $_GET;
// if condition for you parameter
if (...) {
$title="whatever";
}
return $title;
}
add_filter('the_title','alter_title_wpse_82196');
And add the description with something similar.
function add_descr_wpse_82196() {
global $_GET;
// if condition for you parameter
if (...) {
$description = 'properly constructed meta description tag';
}
echo $description;
}
add_action('wp_head','add_descr_wpse_82196');
But that is a rough guide. Theme peculiarities may cause trouble.