• Resolved jdjenkins

    (@jdjenkins)


    I run a large multisite installation wherein I’d like to automatically append the organization name (or main site title) to the page titles of all subsite pages. Like so – Page Title | Subsite Title | Main Title. Is there a function I can use to to filter the page title and append this string if site_id isn’t 1 ro something similar?

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

    (@cybr)

    Hello!

    You can filter the_seo_framework_blog_name. It accepts a simple string, e.g. (untested):

    add_filter( 'the_seo_framework_blog_name', function( $blogname ) {
    
        $main_site_id = get_main_site_id();
    
        if ( $main_site_id === get_current_blog_id() ) 
            return $blogname;
    
        // We could also use <code>get_bloginfo()</code>, but we'd have to switch_to_blog() first.
        $main_blogname = get_blog_option( $main_site_id , 'blogname' );
    
        return trim( "$blogname | $main_blogname" );
    } );
    • This reply was modified 1 year, 7 months ago by Sybre Waaijer. Reason: code comment correction
    Thread Starter jdjenkins

    (@jdjenkins)

    Filter works great! I ended up just hardcoded the main blog name to avoid the switch_to_blog (which I already abuse too much). Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multisite filter to add main site title to end of subsites?’ is closed to new replies.