How to show only Title value without rest of value?

It seems TITLE TAG is not defined inside a custom theme as it will not be returned positive return.

    if ( ! current_theme_supports( 'title-tag' ) ) {
        return;
    }

When I try to echo another title variable, it will be shown also rest part on the right-hand side:
About Us Blog – Example.com

How to manage only pure title value as the bottom code will not work:

$title = wp_title( '', false, 'right' );
echo $title;

In WordPress, the wp_title() function is often used to generate the title tag of a page. However, this function includes the site name and description by default, which is why you’re seeing “About Us Blog – Example.com” instead of just “About Us Blog”.

To get only the title of the page without the site name and description, you can use the get_the_title() function instead. This function returns only the title of the current post or page.

Here’s how you can use it:

$title = get_the_title();
echo $title;

Please note that get_the_title() must be used inside The Loop if you want to get the title of a post or page. If you’re outside The Loop, you need to provide a post ID as an argument.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.