Last active
          September 15, 2023 03:36 
        
      - 
      
- 
        Save bhongy/6761732 to your computer and use it in GitHub Desktop. 
    Wordpress: Check if the_content is empty / do something only when the_content is empty
  
        
  
    
      This file contains hidden or 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 if ( get_the_content() ) { ?> | |
| // do or output something | |
| <?php } ?> // break php tag for HTML block | 
That worked for me @drdogbot7 !
Thanks
Thanks, @drdogbot7! Updated the gist per your suggestion.
if ( get_the_content() ) { // do whatever! }
thanks you for question
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
No need to use empty(), this works fine:
If your post is empty,
get_the_contentwill return an empty string, and in an IF statement PHP will interpret an empty string as FALSE.https://www.php.net/manual/en/language.types.boolean.php