• Resolved skvwp

    (@skvwp)


    Dear Sir,

    I recently installed your plugin. Great! I have the following issue.

    I decided to use ‘document title separator as ?

    This was save in the backend setting in plugin

    Then I checked the output. I can see two title separators as follows:

    ??? ???? ??? ???????? (Red Light and Sperm) ? : ??????? …

    I realized that The : (colon) is coming from a code in the header.php in the theme from this code.

    <title><?php wp_title(‘ ‘); ?> <?php if(wp_title(‘ ‘, false)) { echo ‘ : ‘; } ?><?php bloginfo(‘name’); ?></title>

    What should I do now. I want a setting that if the title separator is defined via seo framework, the default separator from theme dont show up. And if seo framework is not installed, it is define via code in header.php of theme.

    Sorry for long post. Hope I could explain properly.

    You can see the double title separator live here:

    https://vigyaan.org/article/106/

    I wait for your reply. Regard

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter skvwp

    (@skvwp)

    Update on above question

    I changed the line

    <title><?php wp_title(‘ ‘); ?> <?php if(wp_title(‘ ‘, false)) { echo ‘ : ‘; } ?><?php bloginfo(‘name’); ?></title>

    To the following:

    <title><?php
    // Print the <title> tag based on what is being viewed.
    global $page, $paged;

    wp_title( ‘|’, true, ‘right’ );

    // Add the blog name.
    bloginfo( ‘name’ );

    // Add the blog description for the home/front page.
    $site_description = get_bloginfo( ‘description’, ‘display’ );
    if ( $site_description && ( is_home() || is_front_page() ) )
    echo ” | $site_description”;

    // Add a page number if necessary:
    if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() )
    echo esc_html( ‘ | ‘ . sprintf( __( ‘Page %s’, ‘twentyeleven’ ), max( $paged, $page ) ) );

    ?></title>

    Is this OK?

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi @skvwp,

    You should replace all from <title> to </title> with only this:

    <title><?php wp_title( '' ); ?></title>
    

    For an even better solution, look at this page:
    https://codex.www.ads-software.com/Title_Tag

    That page suggests removing all of the title output in header.php, and adding this to functions.php instead (which is also much faster and more reliable):

    add_theme_support( 'title-tag' );
    

    I hope this helps!

    Thread Starter skvwp

    (@skvwp)

    Great! For the moment, the copy paste code from tweetyeleven theme is working fine. I am a beginner and dont want to mess up with function.php

    Yes, in the copy paste code below, if you could please suggest me the meaning of this string, I shall be grateful. What shall I do with ‘Page %s’, ‘twentyeleven’. I am not using twentyeleven theme, just copied the code from there.

    // Add a page number if necessary:
    if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() )
    echo esc_html( ‘ | ‘ . sprintf( __( ‘Page %s’, ‘twentyeleven’ ), max( $paged, $page ) ) );

    <title><?php
    // Print the <title> tag based on what is being viewed.
    global $page, $paged;

    wp_title( ‘|’, true, ‘right’ );

    // Add the blog name.
    bloginfo( ‘name’ );

    // Add the blog description for the home/front page.
    $site_description = get_bloginfo( ‘description’, ‘display’ );
    if ( $site_description && ( is_home() || is_front_page() ) )
    echo ” | $site_description”;

    // Add a page number if necessary:
    if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() )
    echo esc_html( ‘ | ‘ . sprintf( __( ‘Page %s’, ‘twentyeleven’ ), max( $paged, $page ) ) );

    ?></title>

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi @skvwp,

    I strongly advise against using a theme from 2011 (i.e. Twenty[20] Eleven[11]) as a boilerplate for your code. It’s built on outdated standards, which are even considered blatantly wrong by today’s.

    Stick with the code I provided you, and you’re all set! Here it is, once more:

    <title><?php wp_title( '' ); ?></title>
    

    About sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) );:
    It’s used for pagination, where %s gives the current page number built from the max() function call.
    $paged and $page are used in archives and singular paginated pages, respectively. They return the page number.

    All this and much more is done within The SEO Framework and WordPress itself.
    Please, don’t use Twenty Eleven’s code, use Twenty Seventeen! ??

    P.S. You can use the code button above in the comment field (or backticks) if you wish to insert code; these forums convert the code into broken pieces of software otherwise.

    Thread Starter skvwp

    (@skvwp)

    OK.
    I did the following

    1. Deleted the <title></title> tag completely from the header.php i.e the following line

    <title><?php wp_title(' '); ?> <?php if(wp_title(' ', false)) { echo ' : '; } ?><?php bloginfo('name'); ?></title>

    2. Added the following line in the function.php of the theme (above the ‘init’ function (I.E. ABOVE THE LINE – add_action( 'init', 'theme_widgets_init' );

    add_action( 'after_setup_theme', 'theme_slug_setup' );
    
    function theme_slug_setup() {
    
    	add_theme_support( 'title-tag' );
    }

    https://vigyaan.org/article/388/

    THINGS SEEMS TO BE WORKING FINE NOW. ALL SEEMS OK. MAY I KINDLY REQUEST YOU TO PLEASE COMMENT IF THE ABOVE WHAT I DID WAS OK?? I USED JUST COMMON SENSE, AND I HAVE NO IDEA ABOUT CODES!!! I AM SO SORRY TO BOTHER YOU.

    • This reply was modified 7 years, 10 months ago by skvwp.
    • This reply was modified 7 years, 10 months ago by skvwp.
    Plugin Author Sybre Waaijer

    (@cybr)

    Hi @skvwp,

    No worries ??

    1. Good! It was the right thing to do.
    2. Also good! See below if you want to perfect.

    What you have now is for external injection (like from a plugin):

    add_action( 'after_setup_theme', 'theme_slug_setup' );
    function theme_slug_setup() {
    	add_theme_support( 'title-tag' );
    }

    It can be simplified to just this, but only if it’s in your theme’s functions.php file:

    add_theme_support( 'title-tag' );
    

    I’m marking this topic as resolved, as you’ve basically solved it now already.

    Cheers ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to fix double title seperator’ is closed to new replies.