WordPress PHP seo

Include Title in Meta Description Using WordPress PHP

This article introduces how to automatically include the same string as the title at the beginning of the meta description using the PHP language and WordPress API. This is one of the SEO measures I used to do. Uses the All in One SEO Pack filter hook...

Shou Arisaka
1 min read
Oct 29, 2025

This article introduces how to automatically include the same string as the title at the beginning of the meta description using the PHP language and WordPress API. This is one of the SEO measures I used to do. Uses the All in One SEO Pack filter hook.

The following example is code that includes the same string as the title at the beginning of the meta description. If the meta description already contains the title, it cancels.

Copy and paste the following PHP into header.php or functions.php.

<!--?php

     function my_description($description) {
      global $post;

        if ( strpos( $description , $post--->post_title) !== false) {
// do nothing
} else {

if ( substr( $post->post_title , -1) == "ใ€‚"){

$description = $post->post_title."".$description;

} else {

$description = $post->post_title."ใ€‚".$description;

}
}
return $description;
}
add_filter('aioseop_description', 'my_description');

?>

Share this article

Shou Arisaka Oct 29, 2025

๐Ÿ”— Copy Links