• Hello, everyone. This shouldn’t be difficult, but I can’t figure it out. By default, WordPress doesn’t add any meta description tags. They have to be added manually, or by using a plugin.

    I’ve tried adding this to my header:
    <meta name="description" content="My meta description for my website" />

    …but that’s not correct because it’ll add that to ALL pages and posts.

    Does someone know of a query I can use inside the header that allows me to use my main site description for only the homepage and uses the title of the post, for posts?

    I don’t want a plugin for this.

Viewing 8 replies - 16 through 23 (of 23 total)
  • Thread Starter kmcminn

    (@kmcminn)

    So now it seems no one really knows what’s going on. ??

    Without being able to see the source code of your page (you can add a link here so we can see it), I’d be about 99% sure that you’ve got an extra /> in your code somewhere. It’s most likely that it’s after that code that you’ve posted. I’ve done it before a whole heap of times, so it’s not eactly uncommon.

    Thread Starter kmcminn

    (@kmcminn)

    @catacaustic

    Thanks for the quick reply. Are you saying that the extra /> is already present, without me even implementing this code change? Here’s my site, so you can take a look.

    the extra characters /> could not have come from the added meta description code;

    also, right now, I don’t see them in your site.

    to double-check, you can post the full code of header.php of your theme here.

    Thread Starter kmcminn

    (@kmcminn)

    @alchymyth

    Let me ask you this then. Am I supposed to be adding this code directly to the header.php file, or can I add it to the “Header Code” portion of in the template settings, accessible via the WordPress Dashboard?

    I’ve been adding that code via Dashboard. Does that matter?

    you will need to contact your theme’s developer with that question;
    the “Header Code” portion of in the template settings seems to be theme specific, and because your theme is not from https://www.ads-software.com/themes/, we cannot comment on this issues.

    Thread Starter kmcminn

    (@kmcminn)

    @alchymyth

    I’ll try adding it directly to the header.php and let you know what the result is.

    Thread Starter kmcminn

    (@kmcminn)

    Hey! It worked! Thanks very much. I had to manually add it to the header.php, instead of the Dashboard.

    Once again, for reference, here’s the code I used:

    <meta name="description" content="<?php if( is_front_page() ) { ?>
      your meta description for the home page
    <?php } elseif ( is_single() ) {
      single_post_title();
    } else {
      bloginfo('name'); echo " - "; bloginfo('description');
    } ?>" />

    One quick question about that!

    I want this portion:

    single_post_title()

    …to return an opening snippet of the post, rather than the title of the post. Any ideas?

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Meta Descriptions’ is closed to new replies.