I followed instruction by @pat-j and @cjbj in this answer: Dynamically Override Fancy Title and I got the result of override title.
Now I need to dynamically change this title.
I have written this function:

add_filter ('presscore_get_page_title','netbooking_presscore_get_page_title',10,1);
function netbooking_presscore_get_page_title ( $title ) {

if(  is_page( '1057' ) ){

    $GLOBALS["content"] = $content;

// This reads input considering a default value in case of error

$INPUT = function($param, $default, $prefix = true){
            $key = $prefix ? 'netbooking_structure_'.$param : $param;
            return isset($GLOBALS["content"][$key]) ? $GLOBALS["content"][$key] : $default;
        };

// This read GET input

$language = $INPUT('language', 'it', false);
        $lang = substr($language, 0, 2);
        $upwd = $INPUT('upwd', '8UDW37tF', false);
        $cryptedID = $INPUT('crypted_id', 'Nel6LjH9xZ4=', false);
        $structure_id = $INPUT('sid', 268, false);
        $accomodation_id = $INPUT('aid', '4894', false);

// This calls and gets the XML with accomodation data

$today = getdate();
        $api = 'http://url';
        $query = http_build_query([
            'get' => 'getaccomodation',
            'upwd' => $upwd,
            'id' => $structure_id,
            'idacc' => $accomodation_id,
            'type' => 'p',
            'mode' => 'xml',
            'ukey' => 'create',
            'l' => $lang,
            'dstart' => $today['mday'],
            'mstart' => $today['mon'],
            'ystart' => $today['year'],
        ]);
        $xml = new SimpleXMLElement(file_get_contents($api. '?' . $query));
        $accomodation = $xml->accomodation;
    // Ottengo l'XML del prezzo della accomodation
    $api = 'http://netbooking.naturalbooking.it/getnbdata.php';
    $query = http_build_query([
        'get' => 'accomodationminprice',
        'upwd' => $upwd,
        'id' => $structure_id,
        'idacc' => $accomodation_id,
        'type' => 'p',
        'mode' => 'xml',
        'ukey' => 'create',
        'l' => $lang,
    ]);
    $priceData = new SimpleXMLElement(file_get_contents($api. '?' . $query));

// Here we get link for current accomodation

$link = 'http://url';
        $query = http_build_query([
            'cmd' => 'bookstep1',
            'id' => $cryptedID,
            'type' => 'p',
            'l' => $lang,
            'idacc' => $accomodation_id
        ]);
        $link = $link. '?' . $query;

// Local settings

setlocale(LC_TIME, $language);

// Get the title

    $accomodation->id;
    if ($accomodation){

          foreach($accomodation as $accomodation) {
         $title = $accomodation->name_struct." ".$accomodation->name;
         }
         }
    }   
  return $title;
         }

It always returns the name of the first accomodation in list instead of the current accomodation name.

Read more here: Dynamically Override Fancy Title – Part II


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: