• Resolved Guido

    (@guido07111975)


    Hi,

    I have added the title-tag in file functions and removed wp_title tag from file header.

    Because I want to display document title in WP 4.0 and older I have also added the backwards compatibility from the codex:

    if ( ! function_exists( '_wp_render_title_tag' ) ) :
    	function mytheme_render_title() {
    		echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
    	}
    	add_action( 'wp_head', 'mytheme_render_title' );
    endif;

    And I have added the blog title to function above using this default code:

    function mytheme_wp_title( $title ) {
    	global $paged, $page;
    
    	if ( is_feed() )
    		return $title;
    
    // Add the site name.
    	$title .= get_bloginfo( 'name' );
    
    	return $title;
    }
    add_filter( 'wp_title', 'mytheme_wp_title' );

    Theme Check plugin AND Theme Check while submitting theme to themes directory fails:

    Results of Automated Theme Scanning: Fail
    REQUIRED: The <title> tags can only contain a call to wp_title(). Use the wp_title filter to modify the output

    I’ve read this was fixed for online Theme Check, but I think it is not.

    Guido

    https://www.ads-software.com/plugins/theme-check/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Nope, it is definitely fixed. Confirmed and everything. Check your theme again.

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Instead of using this:

    echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";

    Use this:

    ?>
    <title><?php wp_title( '|', true, 'right' ); ?></title>
    <?php

    The check doesn’t expect you to use echo statements and/or to add an action to wp_head like that. It’s specifically checking for the title tag in an inline fashion, because that’s the way most older themes contain it, directly in the head section of header.php.

    Thread Starter Guido

    (@guido07111975)

    Ok, with false statement it did not work, but with true statement it did display in WP 4.0:

    if ( ! function_exists( '_wp_render_title_tag' ) ) :
    	function mytheme_render_title() {
    		?>
    		<title><?php wp_title( '|', true, 'right' ); ?></title>
    		<?php
    	}
    	add_action( 'wp_head', 'mytheme_render_title' );
    endif;

    I guess the codex should be updated with this fix?
    https://codex.www.ads-software.com/Title_Tag

    Guido

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Correct, I’ve updated the codex and the general post to have the corrected code.

    Thread Starter Guido

    (@guido07111975)

    Great, now I can finaly upload new version of my themes ??

    Thanks!

    Guido

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Added title-tag and removed wp_title from header > fail’ is closed to new replies.