WordPress / WordPress/WordPress-Coding-Standards

Flag use of `the_title()` within a HTML element attribute

Open
#1,235 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Focus: Code analysis Focus: WP interoperability Type: Enhancement
Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Description

Using the_title() within a HTML attribute is incorrect. Instead, the_title_attribute() should be used.

Nonsensical example:

<img src="http://example.org/test.jpg" alt="<?php the_title_attribute();">

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named in the issue. Start by locating the PHP_CodeSniffer sniff that checks WordPress function usage, then inspect its existing tests and identify where HTML attribute contexts are parsed. Done means the incorrect use of the_title() in an HTML attribute is flagged and the_title_attribute() is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.