0

i'm developing a theme. I read there that themes should have the support to title tags declaring it in functions.php. I did so, together with removing any title in head.php, but my index has no title.

My functions.php has this:

add_action("after_setup_theme", "mytheme_setup");

function mytheme_setup () {
    load_theme_textdomain('mytheme');
    add_theme_support( 'title_tag' );
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size(356, 245);
}

Now header.php, very basic atm

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <?php endif; ?>
    <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> 
    <?php wp_head(); ?>
</head>

As final note, i should say that not even the way with wp_title() worked. The only way to show something is to put some bloginfo() thing. Any help would be appreciated.

15
  • what does echo wp_get_document_title() output?
    – Milo
    Commented May 13, 2017 at 17:30
  • It prints what i'd like to have as title. Should i just put it inside a <title> tag? Commented May 13, 2017 at 17:36
  • No, that was just a test. That's what ultimately gets called when wp_head is invoked, calling all functions hooked to the wp_head action. What about echo current_theme_supports( 'title_tag' ), what does that output?
    – Milo
    Commented May 13, 2017 at 17:41
  • Nothing, not even true or false. Commented May 13, 2017 at 17:45
  • 1
    Subtle, but dangerous. I wrote "title_tag" in my functions.php, but it is title-tag. Of course it wouldn't work... Commented May 13, 2017 at 22:18

2 Answers 2

1

I did a typo in funcions.php, typing title_tag instead of title-tag.

add_theme_support( 'title-tag' );
0

Which version of wordpress you are using. If its older version then you need Backwards Compatibility as mentioned here:

https://codex.wordpress.org/Title_Tag

Also make sure to switch theme again.

1
  • Version 4.7.4. Compatible as far as i know. Commented May 13, 2017 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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