Title: Add a variable to wordpress function
Last modified: August 19, 2016

---

# Add a variable to wordpress function

 *  Resolved [newkind](https://wordpress.org/support/users/newkind/)
 * (@newkind)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/add-a-variable-to-wordpress-function/)
 * Hi,
 * I’d like to assing a variable to function ie.
 * `$something = the_excerpt();`
 * but everytime i do so, the_excerpt is automatically generated by wordpress … 
   how can i declare such variable without executing this function ?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/add-a-variable-to-wordpress-function/#post-1124807)
 * If in a ‘standard post loop’, try `$post->post_excerpt`.
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/add-a-variable-to-wordpress-function/#post-1124855)
 * It’s proberly because..
    `the_excerpt();` Returns it’s value…
 * Use..
    `get_the_excerpt()` Example.. `$myvar = get_the_excerpt();`
 * ** Or perhaps Michael’s suggestion.. **
 * 😉
 *  Thread Starter [newkind](https://wordpress.org/support/users/newkind/)
 * (@newkind)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/add-a-variable-to-wordpress-function/#post-1124908)
 * thank you all for your replies 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Add a variable to wordpress function’ is closed to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [newkind](https://wordpress.org/support/users/newkind/)
 * Last activity: [16 years, 9 months ago](https://wordpress.org/support/topic/add-a-variable-to-wordpress-function/#post-1124908)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
