Skip to content

Instantly share code, notes, and snippets.

@marcelotorres
Created January 12, 2017 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelotorres/e2fdeccd18702b1714a4c56dabd7a8d7 to your computer and use it in GitHub Desktop.
Save marcelotorres/e2fdeccd18702b1714a4c56dabd7a8d7 to your computer and use it in GitHub Desktop.
Verificar se há uma determinada string no conteúdo de um post do WordPress: http://www.marcelotorresweb.com/verificar-se-ha-uma-determinada-string-no-conteudo-de-um-post-do-wordpress/
<?php
/*
* Verificar se há uma determinada string no conteúdo de um post do WordPress
*/
function is_string_in_content( $string )
{
global $post;
if ( strpos( get_post_field('post_content', $post->ID), $string ) !== false)
return true;
}
/*Exemplo de uso
if(is_string_in_content('WordPress')){
echo 'Existe o termo WordPress';
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment