Shaun Taylor
Shaun Taylor

Reputation: 972

Remove Wordpress title from parent theme

this is a bit of a rehash of a previous question I asked, but I now I have a clearer idea of what I'm asking...

I have the following code, which is in my parent theme and generates the tag for my site... this is located in the directory: themes/kalium/inc/laborator_filters.php

// 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 );

So, I'm trying to disable this from my child theme functions.php file using the following code with no success:

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

I also tried adding it inside its own function like so:

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

    function remove_head_title() {

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

Still with no success.

I have also tried to just copy the original code into my functions file so I could make alterations, but it didn't work.

Can anyone see where I'm going wrong? Getting rid of it completely would be ideal but i would also be happy to just copy it into my child theme so I can alter it?

--------- UPDATE ----------

Ive just updated my code the the following:

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

    //change page title
add_filter( 'wp_title', 'change_page_title', 1000 );

function change_page_title($title)
{
   $title = 'wrgergdg'; // set new title here 
   // $title = ''; // or set title to an empty string
   return $title;
}

But still doesn't seem to be working...

Upvotes: 0

Views: 307

Answers (2)

Shaun Taylor
Shaun Taylor

Reputation: 972

Ok, Ive found this code to work perfectly... Thanks everybody for your help and patience :)

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

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

Upvotes: 0

Alireza Hoseinzadeh
Alireza Hoseinzadeh

Reputation: 606

remove_filter accepts three arguments

remove_filter( $tag, $function_to_remove, $priority );

remove last argument from your code.

Update

//change page title
add_filter( 'wp_title', 'change_page_title', 1000 );

function change_page_title($title)
{
   $title = 'new title'; // set new title here 
   // $title = ''; // or set title to an empty string
   return $title;
}

Upvotes: 1

Related Questions