• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Force a line break in site title

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Force a line break in site title

This topic is: resolved

Tagged: line break, php, site title

  • This topic has 3 replies, 2 voices, and was last updated 11 years ago by SMMP.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • July 16, 2014 at 5:54 am #114502
    SMMP
    Member

    I'm administering some 30 websites with awfully long site titles. Many of them should display in two lines.
    Setting the max-width of site-title for each site and each display size is somewhat cumbersome.
    Does anybody know another way of entering a line break into the site title?

    http://static2.smmp.de
    July 16, 2014 at 5:55 am #114504
    Brad Dalton
    Participant

    Reduce the title area in the CSS or filter the title and add the <br>


    Tutorials for StudioPress Themes.

    July 16, 2014 at 7:45 am #114518
    SMMP
    Member

    Filtering the title is what I had in mind, Brad. Unfortunately, I haven't the faintest clue how to do that.

    July 19, 2014 at 6:53 am #114907
    SMMP
    Member

    I got it done by a very capable company in India.
    Now I can make a line break by entering a simple asterisk (*) in title and description.
    Here's the code for functions.php for everybody to enjoy:

    //// ********************************************************* //////
    //// CUSTOM CODE USED TO GENERATE CUSTOM TITLE AND DESCRIPTION //////
    //// ********************************************************* //////
    
    $new_general_setting = new new_general_setting();
    
    class new_general_setting {
        function new_general_setting( ) {
            add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
        }
        function register_fields() {
            register_setting( 'general', 'custom_blog_info_title', 'esc_attr' );
            register_setting( 'general', 'custom_blog_info_description', 'esc_attr' );
    
            add_settings_field('custom_site_title', '<label for="custom_blog_info_title">'.__('Custom Site Title' , 'custom_blog_info_title' ).'</label>' , array(&$this, 'fields_html_title') , 'general' );
    
            add_settings_field('custom_site_descripition', '<label for="custom_blog_info_description">'.__('Custom Site Description' , 'custom_blog_info_description' ).'</label>' , array(&$this, 'fields_html_desc') , 'general' );
        }
        function fields_html_title() { // Custom Site Title
            $title_value = get_option( 'custom_blog_info_title', '' );
            echo '<input type="text" id="custom_blog_info_title" name="custom_blog_info_title" value="' . $title_value . '" />';
        }
        function fields_html_desc() { // Custom Site Description
            $desc_value = get_option( 'custom_blog_info_description', '' );
            echo '<input type="text" id="custom_blog_info_description" name="custom_blog_info_description" value="' . $desc_value . '" />';
        }
    }
    
    remove_action( 'genesis_site_title', 'genesis_seo_site_title' );
    add_action( 'genesis_site_title', 'custom_genesis_seo_site_title' );
    
    function custom_genesis_seo_site_title() {
    
    	$new_title = get_option( 'custom_blog_info_title' );
    	$new_title = str_replace('*', '<br />', $new_title);
    
    	//* Set what goes inside the wrapping tags
    	$inside = sprintf( '<a href="%s">%s</a>', trailingslashit( home_url() ), $new_title );
    
    	//* Determine which wrapping tags to use
    	$wrap = is_home() && 'title' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p';
    
    	//* A little fallback, in case an SEO plugin is active
    	$wrap = is_home() && ! genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : $wrap;
    
    	//* And finally, $wrap in h1 if HTML5 & semantic headings enabled
    	$wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h1' : $wrap;
    
    	//* Build the title
    	$title  = genesis_html5() ? sprintf( "<{$wrap} %s>", genesis_attr( 'site-title' ) ) : sprintf( '<%s id="title">%s</%s>', $wrap, $inside, $wrap );
    	$title .= genesis_html5() ? "{$inside}</{$wrap}>" : '';
    
    	//* Echo (filtered)
    	echo apply_filters( 'genesis_seo_title', $title, $inside, $wrap );
    
    }
    
    remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
    add_action( 'genesis_site_description', 'custom_genesis_seo_site_description' );
    
    function custom_genesis_seo_site_description() {
    
    	//* Set what goes inside the wrapping tags
    	$inside = esc_html( get_option( 'custom_blog_info_description' ) );
    
    	$inside = str_replace('*', '<br />', $inside);
    
    	//* Determine which wrapping tags to use
    	$wrap = is_home() && 'description' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p';
    
    	//* And finally, $wrap in h2 if HTML5 & semantic headings enabled
    	$wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h2' : $wrap;
    
    	//* Build the description
    	$description  = genesis_html5() ? sprintf( "<{$wrap} %s>", genesis_attr( 'site-description' ) ) : sprintf( '<%s id="description">%s</%s>', $wrap, $inside, $wrap );
    	$description .= genesis_html5() ? "{$inside}</{$wrap}>" : '';
    
    	//* Output (filtered)
    	$output = $inside ? apply_filters( 'genesis_seo_description', $description, $inside, $wrap ) : '';
    
    	echo $output;
    
    }
    
    //// ********************************************************* //////
    //// CUSTOM CODE USED TO GENERATE CUSTOM TITLE AND DESCRIPTION //////
    //// ********************************************************* //////
    
  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble