Okay
  Public Ticket #1270072
Remove Wordpress <title> tags
Closed

Comments

  •  2
    shan_2000_uk started the conversation

    I have added custom fields on every page type so I can easily add my own title and description tags so they are customisable on each and every page. The code I have used for that is here: 

    <title><?php the_field('seo_page_title'); ?></title>
    <meta name="description" content="<?php the_field('seo_page_description'); ?>"/>

    Pulling in the custom fields and displaying them in the header of my pages.

    The trouble I am having is that, when I look at the source code of a page, Wordpress seems to add it's own tag. So my site has two tags. I would prefer to keep my own customised ones and get remove the Wordpress version.

    From your theme files I can't see where the general Wordpress title tags are being pulled in from - Could you point this out please? :)

    Thanks 

  • [deleted] replied

    Hi shan_2000_uk

    This would be easy if you use Yoast Plugin, it i will fix any issue it's popular and works great.

  •  2
    shan_2000_uk replied

    hello,


    Thanks for the reply :) I'm aware of Yoast and  I was hoping to avoid It to be honest, I'm doing everything customised so I can properly control my SEO efforts on each page without a plugin adding lots of unnessesary bits.

    So, if you could let me know where the <title> tag comes from, I can edit this and customise it :) 

    Thanks,

    Shaun

  • [deleted] replied

    Hi shan_2000_uk

    Can you try to edit the function 'kalium_wp_head_open_graph_meta' file location is : themes/kalium/inc/laborator_actions.

    Good Luck.

  •  2
    shan_2000_uk replied

    Hello, 

    Thanks for this, I may be mistaken, but this function looks like it controls the og: tags and not the <title> tag?

    The title tag can be seen highlighted in the screenshot I have attached with the og: tags below it...

    Any ideas where the title tag is generated from? (or indeed, if I'm wrong, which part of that function generates the <title> tag?). 

    Thanks a lot :) 


    Shaun. 


  • [deleted] replied

    Hi shan

    This is the code generates title tag, you can read about it on wp_title

    file location is : themes/kalium/inc/laborator_filters.

    // Title Parts
    function kalium_wp_title_parts( $title, $sep, $seplocation ) {
        $kalium_separator = apply_filters( 'kalium_wp_title_separator', ' – ' );
        
        if ( empty( $sep ) ) {
            return $title;
        }
        
        $title_sep = explode( $sep, $title );
        
        if ( ! is_array( $title_sep ) ) {
            return $title;
        }
        
        if ( $seplocation == 'right' ) {
            $title = str_replace( $sep . end( $title_sep ), $kalium_separator . end( $title_sep ), $title );
        } else {
            $title = str_replace( reset( $title_sep ) . $sep, reset( $title_sep ) . $kalium_separator, $title );
        }
        
        return $title;
    }
    add_filter( 'wp_title', 'kalium_wp_title_parts', 10, 3 );
    
  •  2
    shan_2000_uk replied

    Thanks again Eroll, I really appreciate the help, I think we're getting closer...

    I managed to find the code below initially, but I'm having trouble just disabling the <title> tag. 

    I think I need to delete or overwrite it in my child theme, otherwise when I update the theme, it will overwrite my changes.

    Would I just copy the file and directory into my child theme and make the changes there?

    Thanks, 

    Shaun.


  •  2
    shan_2000_uk replied

    Hi again Eroll,

    I have tried to delete this area of cod you pointed out to see if it makes any difference - unfortunately it doesn't... I delete the code but the <title> tag still appears... 

  • [deleted] replied

    Hi there

    if you deleted it doesn't change yes, cause this function hooks the core function inside wordpress core functions, basically you have to work inside that function or set your setting.

    Tried by taking simple changes to see difference.

  •  2
    shan_2000_uk replied

    I don think I understand - I'm currently trying to remove the <title> tag with this code inside my functions.php in the child theme: 


    add_action( 'after_setup_theme', 'remove_head_title', 0 );

        function remove_head_title() {

    remove_filter( 'wp_title', 'kalium_wp_title_parts', 10 );


    But it doesn't work and now you're saying I shoujnldnt remove it? - Could you help please? 

    Is there another way I can remove the <title> tag? or if I wanted to change it from my child theme, how would i go about doing so?

  • [deleted] replied

    Hi,

    The title is automatically added via "add_theme_support( 'title-tag' );" so here is you can remove the title:

    Can you please add the following code in functions.php (end of file):

    // Remove title tag
    function custom_remove_title_tag() {
    remove_theme_support( 'title-tag' );
    }

    add_action( 'after_setup_theme', 'custom_remove_title_tag', 10000 );

  •  2
    shan_2000_uk replied

    That works perfectly, thanks so much :)

  •  1,559
    Laborator replied

    Glad to hear that it worked, 

    P.S: If you like our theme, it would help us a lot if you could give us five star rating on themeforest from your Downloads tab, (if you don't know how, just open this link).

    A huge thank you from Laborator in advance, wishing you a great week!

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group