Title: return does not work but echo does
Last modified: October 16, 2022

---

# return does not work but echo does

 *  Resolved [andersonkoh](https://wordpress.org/support/users/andersonkoh/)
 * (@andersonkoh)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/return-does-not-work-but-echo-does/)
 * Hi, I’m trying to display my category description on the category archive page.
   However, I face some issues with using `return` at the end of my PHP code, but`
   echo` does the work.
 *     ```
       $category_description = get_queried_object()->category_description;
   
       return $category_description;
       ```
   
 * But adding this in `Theme File Editor` will work with `return`.
    -  This topic was modified 3 years, 7 months ago by [andersonkoh](https://wordpress.org/support/users/andersonkoh/).
    -  This topic was modified 3 years, 7 months ago by [andersonkoh](https://wordpress.org/support/users/andersonkoh/).
    -  This topic was modified 3 years, 7 months ago by [andersonkoh](https://wordpress.org/support/users/andersonkoh/).
    -  This topic was modified 3 years, 7 months ago by [andersonkoh](https://wordpress.org/support/users/andersonkoh/).
    -  This topic was modified 3 years, 7 months ago by [andersonkoh](https://wordpress.org/support/users/andersonkoh/).
    -  This topic was modified 3 years, 7 months ago by [andersonkoh](https://wordpress.org/support/users/andersonkoh/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [Mircea Sandu](https://wordpress.org/support/users/gripgrip/)
 * (@gripgrip)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/return-does-not-work-but-echo-does/#post-16104737)
 * Hi [@andersonkoh](https://wordpress.org/support/users/andersonkoh/),
 * That seems to be working as intended. The code in that snippet will be executed“
   as is” in the location you choose. Return will not output anything but echo will.
   Usually, you would use return at the end of a function, for example, and then
   echo the value returned by the function if you want it to output in the frontend.
 * Adding it in the Theme File Editor depends where you add it, if you are adding
   the code inside a function that then gets called and echoed in a template file,
   it will work.

Viewing 1 replies (of 1 total)

The topic ‘return does not work but echo does’ is closed to new replies.

 * ![](https://ps.w.org/insert-headers-and-footers/assets/icon-256x256.png?rev=2758516)
 * [WPCode - Insert Headers and Footers + Custom Code Snippets - WordPress Code Manager](https://wordpress.org/plugins/insert-headers-and-footers/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-headers-and-footers/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-headers-and-footers/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 2 participants
 * Last reply from: [Mircea Sandu](https://wordpress.org/support/users/gripgrip/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/return-does-not-work-but-echo-does/#post-16104737)
 * Status: resolved