Support » Plugin: Yoast SEO » disable/change title programmatically

  • Resolved Insomnia88


    Hi, I have a problem with the title tag. I am using a customized twentyseventeen theme with the
    add_theme_support( 'title-tag' )
    feature and yoast installed.

    For some page templates I want to set the title programmatically and tried to do that using the yoast hooks

    function custom_title( $title, $arg1 ){
    	$title = $arg1.' - '.get_bloginfo('name');
    	return $title;
    add_filter('wpseo_title','custom_title', 10, 2);
    apply_filters( 'wpseo_title', 'test', $arg1);

    As you can see I want to pass arguments to the add_filter functions but apply_filter only returns whats inside the custom_title but doesn’t change the <title> tag.. how do I do that?! Ofc this would work without passing arguments and using only add_filter but I need to pass arguments.

Viewing 3 replies - 1 through 3 (of 3 total)
  • If you need more arguments than the filter supplies, you have to think of a different way to do it. Your filter function should check some condition, so it’s not always putting the same thing in the title. The condition would tell you what to put, so you don’t need parameters.
    You wouldn’t typically call the apply_filters function.

    Plugin Support Michael Tina


    We can’t offer support on custom code (needed to change (core) features of our plugin). Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive for 7 days, we’ll mark it as resolved to keep the overview.

    Thank you for your understanding.


    Ok, it seems I missunderstood the way apply_filter works then. I solved my issue with capsuling functions. I just searched for a better way to do it (using wp mechanics)

    • This reply was modified 1 year, 10 months ago by Insomnia88.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘disable/change title programmatically’ is closed to new replies.