Yoast normal title and meta description no longer works when using wpseo api
-
The codes below works in changing title and meta description by query strings. There was only one page with 3 query strings. The other pages do not have query strings. With the codes in functions.php, the other pages Yoast title and metadescription does not work properly. Without the codes, Yoast title and meta description works properly. Is there a way to make the codes work while still using Yoast title and meta description?
/* Changing title and meta description by query strings */ function yoast_add_title (){ if ( ! empty( $_GET[ 'q' ] ) && $_GET['q'] == 'medical' ) { $title = 'Health'; } if ( ! empty( $_GET[ 'q' ] ) && $_GET['q'] == 'wealth' ) { $title = 'Financial'; } if ( ! empty( $_GET[ 'q' ] ) && $_GET['q'] == "retirement" ) { $title = 'Wealth'; } return $title; } function yoast_add_metadesc (){ if ( ! empty( $_GET[ 'q' ] ) && $_GET['q'] == 'medical' ) { $metadesc = 'Health'; } if ( ! empty( $_GET[ 'q' ] ) && $_GET['q'] == 'wealth' ) { $metadesc = 'Financial'; } if ( ! empty( $_GET[ 'q' ] ) && $_GET['q'] == "retirement" ) { $metadesc = 'Wealth'; } return $metadesc; } add_filter( 'wpseo_title', 'yoast_add_title', 10, 1); add_filter( 'wpseo_metadesc', 'yoast_add_metadesc', 10, 1);
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Yoast normal title and meta description no longer works when using wpseo api’ is closed to new replies.