• Hi,

    I have wordpress website. I have created pages and website title is getting added to page title automatically.

    I want to stop added website title after page title.

    For example

    MY Page Title (coming from page) | My Website Title (coming from settings)

    In header.php file below link bring title.

    <title><?php $theme->meta_title(); ?></title>

    Any idea how to do it?

    Best Regards,
    Shahab
    https://hrms-systems.com

    • This topic was modified 6 years, 11 months ago by Shahab82.
Viewing 5 replies - 1 through 5 (of 5 total)
  • This is a perfectly normal thing to do. The title tag should have enough information in it to be useful to users when looking at their tabs. It also helps contextualise the content in search results. In both cases “About Us” would be a useless title without “- My Company LLC” attached. Pretty much every site does it.

    But if you absolutely want to remove it, you can. Assuming your theme is using the modern method of adding a title tag (See here and here) and are running at least 4.4, then you can remove it with the document_title_parts filter:

    function hrms_remove_site_from_title( $title ) {
    	unset( $title['site'] );
    
    	return $title;
    }
    add_filter( 'document_title_parts', 'hrms_remove_site_from_title' );
    
    • This reply was modified 6 years, 11 months ago by Jacob Peattie.
    Thread Starter Shahab82

    (@shahab82)

    Hi Jacob,

    Many thanks for filter function.

    Please advice where to put this function.

    I tried in functions.php and wp-includes/general-template.php but no success.

    Best Regards,
    Shahab
    https://hrms-systems.com

    • This reply was modified 6 years, 11 months ago by Shahab82.

    functions.php, but as I said it assumes you are using the correct method for setting the title to begin with. Please see the links I included, particularly the second one. Also please take into account everything else I said. Put more bluntly that is: This is a bad idea.

    Thread Starter Shahab82

    (@shahab82)

    The page title is getting very big by adding site title to it.

    therefore I want to remove site title from page title.

    May be my theme is old but I have latest version of wordpress.

    therefore this solution not working for me.

    Best Regards,
    Shahab
    https://hrms-systems.com

    You theme appears to be custom-made for your site, so you should be able to make the modifications outlined in the 2nd link I posted so that this solution does work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Stop adding website title after page title’ is closed to new replies.