I created a shortcode for creating dynamic pages with the help of API data. If someone changes the page title I also want changes.
Now I have a dynamic page title in a shortcode function, but I need to run that variable in the 2nd function too.
1st Function Code:
$mainiid = $_GET['stattype'];
$title_new = $_GET['titype'];
$z123 = $title_new;
2nd Function code:
function custom_titles($z123) {
global $wp;
$current_slug = $wp->request;
if ($current_slug == 'demo') {
return $z123 . 'Foobar';
print_r($z123);
}
}
add_filter('wpseo_title', 'custom_titles', 10, 1);
I'm using Yoast plugin and my dynamic title was stored in var $z123
in the first function.