• Resolved rik1234

    (@rik1234)


    Hi,
    we run a donation platform for charities. We use your plugin to manage our SEO. For our regular pages, the current default meta-title works fine:

    <page title> – <site title>

    However, every charity has a page on our site to. For these pages, we would like to have the default meta-title:

    Donate to <page title> via <site title>

    We can do this manually of course on the charity pages, but we have 100s of charities, so if we ever want to make a change to the format, it will be very time consuming. Is there a way to create 2 different default meta-titles, and apply 1 to our regular pages and the other to our charity pages?

    thanks,
    Rik

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Rik,

    If you can detect the charity pages, you can exchange the hyphen separator with ‘via’ easily using filter the_seo_framework_title_separator. For example:

    add_filter( 'the_seo_framework_title_separator', function( $sep ) {
    
    	if ( is_singular( 'give_forms' ) )
    		$sep = 'via';
    
    	return $sep;
    } );
    • This reply was modified 3 years, 3 months ago by Sybre Waaijer. Reason: validated code
    Thread Starter rik1234

    (@rik1234)

    ah thanks this is helpful. Is there also a way to put something before the page title, so we for example:
    – put “Donate to” before page title
    – put “via” as a separator using your method above
    so we get:

    Donate to <page title> via <site title>
    ?

    Thread Starter rik1234

    (@rik1234)

    Hi @cybr , any thoughts on this, on how to add something BEFORE the page title by default for certain types of pages?

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Rik,

    Sorry for the delay! The release of v4.2.0 must’ve made me miss your reply.

    You can add “Donate to” in front of the title, yes.

    This ought to do the trick:

    add_filter( 'the_seo_framework_title_from_generation', function( $title, $args ) {
    
    	if ( is_singular( 'give_forms' ) )
    		$title = "Donate to $title";
    
    	return $title;
    }, 10, 2, );

    We’re planning to add title syntax as an extension that will remove the need for filters. You can track that feature here: https://github.com/sybrew/the-seo-framework/issues/140.

    Thread Starter rik1234

    (@rik1234)

    Thanks, this worked perfectly.

    For other WordPress admins who need to do this for multiple languages, here is how to do it with a multilingual setup:

    add_filter( 'the_seo_framework_title_from_generation', function( $title, $args ) {
     
    		if (is_singular( 'give_forms' ) && get_locale() == 'en_GB')
    
    		$title = "Support the future of $title";
    
    	return $title;
    }, 10, 2, );
    
    add_filter( 'the_seo_framework_title_from_generation', function( $title, $args ) {
     
    		if (is_singular( 'give_forms' ) && get_locale() == 'nl_NL')
    
    		$title = "Steun de toekomst van $title";
    
    	return $title;
    }, 10, 2, );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Multiple default meta-titles’ is closed to new replies.