Title: Include text in code
Last modified: November 24, 2022

---

# Include text in code

 *  Resolved [José Antonio Pons](https://wordpress.org/support/users/japonsm/)
 * (@japonsm)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/include-text-in-code/)
 * Hola!
 * How text should be concatenated to the code added in the category template:
 * <?php if(function_exists(‘rdv_category_image’)){ rdv_category_image(); } ?>
 *  … so that it shows up on the page next to the image?
 * e.g. “Sponsored by” [IMAGE]
 * Thank you,
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Finclude-text-in-code%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [rdvinfotech](https://wordpress.org/support/users/rdvinfotech/)
 * (@rdvinfotech)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/include-text-in-code/#post-16237809)
 * Hi [@japonsm](https://wordpress.org/support/users/japonsm/)
 * Thanks for reaching out. You can use the template tag just after the text.
 *  Thread Starter [José Antonio Pons](https://wordpress.org/support/users/japonsm/)
 * (@japonsm)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/include-text-in-code/#post-16240337)
 * Hi, thanks for your support.
 * I have inserted the code with this format:
    <?php if(function_exists(‘rdv_category_image’)){
   echo ‘Patrocinat per ‘; rdv_category_image(); } ?>
 * The text appears correctly before the image. However, this text also appears 
   on category pages where no image is defined.
 * With this code I’m trying to detect if the function returns an image so I can
   discard the text when it’s not needed:
 * <?php if(function_exists(‘rdv_category_image’)){
    if ( true === rdv_category_image()){
   echo ‘Patrocinat per ‘; rdv_category_image(); } } ?>
 * I have also tried this other way:
 * <?php if(function_exists(‘rdv_category_image’)){
    if ( true === rdv_category_image()){
   echo ‘Patrocinat per ‘ . rdv_category_image(); } } ?>
 * In both cases the image is displayed but the text is not displayed.
 * How could I detect if the function returns an image so that I can discard the
   text when it’s not needed?
 * Thanks in advance.
 *  Plugin Author [rdvinfotech](https://wordpress.org/support/users/rdvinfotech/)
 * (@rdvinfotech)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/include-text-in-code/#post-16240570)
 * Hi [@japonsm](https://wordpress.org/support/users/japonsm/)
 * You can use this function rdv_category_image_url() to detect the image or image
   URL. Please check these two examples.
 *     ```
       <?php if( function_exists('rdv_category_image_url') && !empty(rdv_category_image_url()) ){
           echo 'Patrocinat per <img src="'.rdv_category_image_url().'">';
       } ?>
       ```
   
 *     ```
       <?php if( function_exists('rdv_category_image') && !empty(rdv_category_image_url()) ){
           echo 'Patrocinat per ';
           rdv_category_image();
       } ?>
       ```
   
 *  Thread Starter [José Antonio Pons](https://wordpress.org/support/users/japonsm/)
 * (@japonsm)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/include-text-in-code/#post-16241230)
 * The proposed solution works perfectly.
 * Thank you,

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

The topic ‘Include text in code’ is closed to new replies.

 * ![](https://ps.w.org/rdv-category-image/assets/icon-256x256.png?rev=2599260)
 * [RDV Category Image](https://wordpress.org/plugins/rdv-category-image/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/rdv-category-image/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/rdv-category-image/)
 * [Active Topics](https://wordpress.org/support/plugin/rdv-category-image/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/rdv-category-image/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/rdv-category-image/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [José Antonio Pons](https://wordpress.org/support/users/japonsm/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/include-text-in-code/#post-16241230)
 * Status: resolved