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.

  • what does echo wp_get_document_title() output? – Milo May 13 '17 at 17:30
  • It prints what i'd like to have as title. Should i just put it inside a <title> tag? – Daniele Squalo May 13 '17 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 May 13 '17 at 17:41
  • Nothing, not even true or false. – Daniele Squalo May 13 '17 at 17:45
  • @Milo Sorry i just seen now. It returns 1. I suppose this is alright. – Daniele Squalo May 13 '17 at 17:53
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.

  • Version 4.7.4. Compatible as far as i know. – Daniele Squalo May 13 '17 at 19:46
0

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

add_theme_support( 'title-tag' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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