Created
January 12, 2017 15:23
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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