Is it possible to add meta title, meta description, meta keywords in every page without installing plugin?

My client require not to install plugin. I am curious about this case, all I know is the admin should install the seo plugin in their wordpress to have an insertion of meta.

  • You will have to create custom fields for each and call their values in header.php or you can also create a function to automatically use content/excerpt for meta description & category/tag for meta keyword. It's fairly easy.
    – Robert hue
    Commented Sep 5, 2014 at 10:06
  • "My client require not to install plugin." ... why that? Because of the old myth that plugins are dangerous or hurt performance? Please explain why you want to do it that way. It could be that you are facing a XY Problem.
    – kaiser
    Commented Sep 5, 2014 at 10:10
  • Hi Sir Robert, is there another way adding without plugin not to edit the code? Hi Sir Kaiser, the client doesn't want to install plugin, they want to add automatically in wordpress without installing any plugin..all the forum I read, they're requiring to install plugin or edit the header.php...... Commented Sep 5, 2014 at 10:24
  • Without editing theme files, it's not possible. You will have to edit theme files, specially functions.php. If that's OK then I can post a solution.
    – Robert hue
    Commented Sep 5, 2014 at 10:37
  • Agreed with @kaiser. For SEO, stick with well known plugins like YOAST. If you and your client are not comfortable with SEO, use plugins. SEO is a specialist field, one that I'm not comfortable with even. Commented Sep 5, 2014 at 11:13

2 Answers 2


Although I would advice you to avoid this and use a plugin for this work. Because only a dedicated plugin can help SEO. "WordPress SEO" from yoost is a great plugin for SEO.

That being said, here is the code for adding meta description and keywords in header. Paste this in theme's functions.php file.

function add_meta_tags() {
    global $post;
    if ( is_single() ) {
        $meta = strip_tags( $post->post_content );
        $meta = strip_shortcodes( $post->post_content );
        $meta = str_replace( array("\n", "\r", "\t"), ' ', $meta );
        $meta = substr( $meta, 0, 125 );
        $keywords = get_the_category( $post->ID );
        $metakeywords = '';
        foreach ( $keywords as $keyword ) {
            $metakeywords .= $keyword->cat_name . ", ";
        echo '<meta name="description" content="' . $meta . '" />' . "\n";
        echo '<meta name="keywords" content="' . $metakeywords . '" />' . "\n";
add_action( 'wp_head', 'add_meta_tags' , 2 );
  • How can those meta tags set when using XML-RPC to access wordpress?
    – Amit Patel
    Commented Jan 1, 2016 at 11:50

It is always a good opportunity to have dedicated SEO plugin for WordPress site, But somehow if I ignore the plugin and straight to the question adding meta tag without a use of SEO plugin, I would suggest add them to header.php file in your WordpPress theme at the head section near the style sheet link.

Look at <title> tag and you can see something like <title><?php bloginfo('name'); ?><?php wp_title(); ?></title> this. You can add your meta tags just below this line. All type of the meta tags you can add here and it would work normally without conflict to the theme codes!

Not the answer you're looking for? Browse other questions tagged or ask your own question.