E
E
Eugene2016-04-11 09:21:01
WordPress
Eugene, 2016-04-11 09:21:01

Why doesn't the pre_get_document_title filter work?

Trying to use the wp_get_document_title function in a plugin

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

add_filter( 'pre_get_document_title','sm_pre_get_document_title');
function pre_get_document_title(){
  global $post;
  if( $post->ID != 6486 ) return; 
  return 'Тест';
}

the title of the page with id 6486 does not change, in which direction to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zhainar, 2016-04-11
@redmo

filter function is called wrong

add_filter( 'pre_get_document_title','sm_pre_get_document_title');
function sm_pre_get_document_title( $param ){
  global $post;
  if( $post->ID != 6486 ) return; 
  return 'Тест';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question