TITLE tag check issue
-
Hi,
Why the plugin only takes
<title><?php wp_title( '', false ); ?></title>
?I am using
$output .= '<title>' . wp_title( '', false ) . '</title>';
which seems to me perfectly fine, but the plugin throws a REQUIRED warning about the title tag.Thanks and regards,
Oliver
-
Yeah, I’m still uncertain about this particular check.
Is there any reason you’re doing the title this particular way instead of simply having the code in the header.php file as the check requires?
Hey Otto,
I’m hooking into
wp_head
instead and outputting the HTML head via a hooked function.Yes, I get that, but my question was is there any reason for doing it this way? You can certainly add title tags using a hook and such, but there’s no real reason to do that. Every page has to have the title, so why not just put it directly in the header.php instead? Why have it in a function hooked to the wp_head hook? What is the purpose of doing such?
I was initially uncertain on the check, but I put it in because I can’t think of any valid reason to have the title in a function like you’re saying, and to not just have it in the header.php directly. Having it in a function adds overhead, confusion, people being unable to find it, etc. Having it in a standard and obvious location makes a lot more sense.
Yes, I agree with what you say. I’ve decided to go the way of hooking because of the child theme use. With my previous themes all the code for HTML head (and other) was put into
header.php
file as usually. When a customer used the theme and wanted to change something in the header, they’ve just modified the file via a child theme. However, when I’ve changed something in theheader.php
file in some of theme updates, most (if not all) of child theme users were not following the parent theme changelog and it happens that some things were “broken” for them. That’s why I’ve decided to build a framework on action hooks. You can see theheader.php
file example here: https://github.com/webmandesign/mustang-lite/blob/master/header.phpPlease, let me know whether you will incorporate the fix in your plugin or should I change the
header.php
file for my themes as I’m doing an update right now.OK, I’ve went ahead and updated my theme framework’s
header.php
file.I want to ask what is wrong with my code
<title><?php wp_title( '|', true, 'right' ); ?></title>
It throws me error in theme check. For me code looks valid. I get error from theme check even if I call
<title><?php wp_title(); ?></title>
May it look into other files then header.php?
With regards.
We actually have a discussion over here talking about the exact same issue.
Alright Air, themecheck.org passed my theme just fine even though theme check was throwing this “title” error. Bug with theme checker?
We do not own themecheck.org and have no control over how it checks things.
The plugin is up-to-date. Can’t vouch for anything else.
Alright, well Samuel in the other topic as you might have read I have rigorsly dug through my code and searched for any other title tags, there are none. I can even send you the theme files if you want and you can run a search on all the files yourself if you wish. Otherwise though your help has been apprciated and your plugin has been fantastic for making sure I’ve got all my bases covered as I learn wordpress.
In the meantime I’m going to keep at this issue. I will post updates here as I figure things out, I’m running the check on an xampp local server so my next step I’m uploading it to my website and running the check again live.
Something you can help with now though, is there a check for if no title exists? Does it say “warning: Missing title tags” or something?
Alright, so I found the solution.
I dove into your plugin and edited the title.php check to echo the file locations that they were checking, it returned two files.
header.php
header(copy).phpYour check goes accross the files, yes but this has clearly lead to some serious confusion, I had assumed it only checked active or official files. I deleted my backup of my header and it passed. I overlooked it because it wasn’t used in any way so I didn’t think it was relevant.
I would recomend either refining the check or simply outputing the locations of the found title tags to save this heartache in the future.
Your code is well structured and documented, It was neat seeing how it all worked.
Best regards.
Hi there
I have checked my theme files and there are few files that contain
<title>
tag but one is file for video player in player.php(executed only for video as it creates iframe), other is some documentation in .html format, also demo data export in .xmlThere are 362
<title>
tags in my theme and 357 are in XML file;-)I won’t bother with debugging which file theme check is referring to, however I want just confirmation that this is issue in plugin not in my theme.
So ? ??
With regards.
Given what I’ve found on the check, it refers to ALL <title> tags in your theme at the same time, not one specific title. That really needs to be clarified in the error.
I would assume for the sake keeping a theme simple and straightforward that having only one title tag in your entire theme would be most efficient, going on the DRY principle, since there is no reason for a page to have more than one title tag, and wordpress obviously has the capability to handle generating titles within a tag.
As far as iframes go I’m not a fan of them but I can’t speak for compatability with them and this plugin or even wordpress.
As far as the XML document goes, to get around this you make your own tags in xml right? Just do a search-replace and rename all your <title> tags to <x-title> then make sure your calls to the file refer to <x-title>? Otherwise just make sure all of your title tags contain the wp_title function.
Just some suggestions, I would definitely await input from the author.
Happy coding!
Actually now that I think about it I wouldn’t think that the check has any business checking an XML file, we need to discuss this with the author on whether XML files should be ignored.
This particular check is only looking at PHP files already.
As for iframes and a player.php file in a theme, a theme that made direct calls to its own files like this would not be accepted anyway for other reasons. Specifically, wp-content isn’t always at /wp-content so you cannot reliably have a directly called file load WordPress in order to access whatever data it’s using. If it’s using no data and receiving everything through the URL, then it’s a security issue, probably vulnerable to XSS attacks.
There is no legitimate reason for a PHP file in a theme to be referred to directly by the URL, like you would do if you’re putting it in an iframe.
- The topic ‘TITLE tag check issue’ is closed to new replies.