• Resolved xales

    (@xales)


    Hi! In the file functions.php to change the TITLE of certain pages, there is a code:

    add_filter( 'document_title_parts', function($title)
    {
    if(!preg_match('#/filter.*#', $_SERVER['REQUEST_URI']))
            return $title;
        global $meta_post_url;
        if($meta_post_url)
        {
            $title['title'] = $meta_post_url->post_title;
            unset( $title['site'] );
            return $title;
        }
    	$myTitle = explode('||', Filter::get_this_names());
      	$title['title'] = 'View '.$myTitle[0];
    	unset( $title['site'] );
      	return $title;
    });

    However, it stopped working after updating the plugin. And it works when the plugin is disabled.

    What happened? How to repair this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author arnaudbroes

    (@arnaudbroes)

    @xales I can’t fully update this code snippet for you but essentially you need to hook into the pre_get_document_title hook with a very high priority like this –

    add_filter( 'pre_get_document_title', function($title)
    {
      	$title = 'View ' . $title;
      	return $title;
    }, 9999999 );

    Note that $title is a string in this case; not an object with multiple properties.

    Let me know if that makes sense.

    Thread Starter xales

    (@xales)

    Working! Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘AISEO and ‘document_title_parts’’ is closed to new replies.