Skip to content

Commit

Permalink
fix: improve remove sitename from title
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen committed Oct 25, 2023
1 parent 79239c3 commit 6de0ada
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions each-domain-a-page/each-domain-a-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ public function get($query)
$slug = $this->slug;
$type = $this->post_types[$slug];
if ($this->remove_sitename_from_title) {
if (false !== has_action('wp_head', '_wp_render_title_tag')) {
remove_action('wp_head', '_wp_render_title_tag', 1);
add_action('wp_head', array($this, 'render_title_tag'), 1);
}
add_filter('wpseo_title', array($this, 'get_title'), 1);
add_filter('document_title_parts', array($this, 'clean_title_parts'));
}
if ('page' === $type) {
unset($query->query_vars['name']);
Expand All @@ -258,13 +254,10 @@ public function get($query)
return $query;
}

/**
* substitute for standard wp title rendering to remove the site name
* @since 1.2.2
*/
public function render_title_tag()
public function clean_title_parts(array $title_parts)
{
echo '<title>', get_the_title(), '</title>';
unset($title_parts['site']);
return $title_parts;
}

/**
Expand Down

0 comments on commit 6de0ada

Please sign in to comment.