Manish Negi
Manish Negi

Reputation: 270

Expected next thing to be an escaping function: WordPress

I created custom Wordpress theme and uploaded on wordpress.org directory. But when it was reviewed, there was some errors which I can't find out the solution.

line 14 Expected next thing to be an escaping function (see Codex for 'Data 
Validation'), not 'the_post_thumbnail_url'
line 17 Expected next thing to be an escaping function (see Codex for 'Data 
Validation'), not '$post'
line 18 Expected next thing to be an escaping function (see Codex for 'Data 
Validation'), not 'substr'

Code in file

<img class="img-fluid" alt="<?php the_title() ?>" src="<?php the_post_thumbnail_url(); ?>" >
<p><?php echo substr($post->post_content, 0, 200).'..'; ?></p>

Upvotes: 0

Views: 121

Answers (1)

Elvin Haci
Elvin Haci

Reputation: 3572

It means you need to use esc_attr function if you are printing any string as an attribute value.

like

alt="<?php echo esc_attr(get_the_title()); ?>"

src="<?php echo esc_attr(get_the_post_thumbnail_url()); ?>"

And instead of $post->post_content use get_the_content() function as well.

Upvotes: 2

Related Questions