Title: custom shortcode php. &#8211; include alt-text for images
Last modified: September 3, 2021

---

# custom shortcode php. – include alt-text for images

 *  [janeric](https://wordpress.org/support/users/janeric/)
 * (@janeric)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/custom-shortcode-php-include-alt-text-for-images/)
 * Hello,
 * for my websites i have some pages that use custom shortcodes. For these shortcodes
   there are some .php-files in the wp-directory. I have access to these .php-files
   and can rewrite them.
    The shortcodes i want to change are about implementing
   the featured image from some custom post types. When including the image, the
   alt-text of the image is not implemented, so the alt-text ends up missing on 
   the live-page. I already read, that this includes some code like “get_post_meta….”,
   but i am not that comfortable including code to a php. file. Can anyone help 
   me?
 * The original code for one of the shortcodes i want to change is
 *     ```
       <?php
       add_shortcode('clients_mixup', 'clients_mixup');
   
       function clients_mixup($atts) {
   
           $terms = get_terms(array(
               'taxonomy' => 'clients_cat',
               'hide_empty' => true,
       	'meta_key' => 'tax_position',
               'orderby' => 'tax_position',
           ));
           $count_terms = count($terms);
   
           $terms_id = array();
           $terms_names = array();
   
           ob_start();
           ?>
           <div class="custom-clients-container-btns">
   
               <div class="controls">
                   <button type="button" class="control" data-filter="all"><?php _e("All", "bertschinnovation"); ?></button>
                   <?php
                   if ($count_terms > 0) {
                       foreach ($terms as $key => $term) {
                           ?>
                           <button type="button" class="control" data-filter=".<?php echo $term->slug; ?>"><?php echo $term->name; ?> </button>
   
                           <?php
                       }
                   }
                   ?>
   
               </div>
   
               <div class="clients-container custom-clients-container" data-ref="mixitup-container">
   
   
                   <?php
                   if ($count_terms > 0) {
                       foreach ($terms as $key => $term) {
   
                           $args = array(
                               'posts_per_page' => -1,
                               "suppress_filters" => false,
                               'post_type' => 'clients_type',
                               'tax_query' => array(
                                   array(
                                       'taxonomy' => 'clients_cat',
                                       'field' => 'term_id',
                                       'terms' => $term->term_id
                                   )
                               )
                           );
                           $clients_array = get_posts($args);
                           $count_clients = count($clients_array);
                           if ($count_clients > 0) {
                               ?>
   
                               <?php
                               foreach ($clients_array as $key => $client) {
   
                                   $image = get_stylesheet_directory_uri() . "/assets/images/default-img.jpg";
                                   if (has_post_thumbnail($client->ID)) {
                                       $image = wp_get_attachment_image_src(get_post_thumbnail_id($client->ID), 'thumbnail');
                                       $image = $image[0];
                                   }
                                   ?>
   
                                   <div class="item mix <?php echo $term->slug; ?>" data-ref="mixitup-target">
                                       <div class="box-content">
                                           <img src="<?php echo $image; ?>" alt="">
                                       </div>
                                   </div>
   
                               <?php }
                               ?>
   
                               <?php
                           }
                       }
                   }
                   ?>
   
                   <div class="gap"></div>
                   <div class="gap"></div>
                   <div class="gap"></div>
               </div>
   
           </div>
   
           <?php
           return ob_get_clean();
       }
       ```
   
    -  This topic was modified 4 years, 9 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Developing with WordPress
      topic
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcustom-shortcode-php-include-alt-text-for-images%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [4 years, 9 months ago](https://wordpress.org/support/topic/custom-shortcode-php-include-alt-text-for-images/#post-14835801)
 * Moved to Fixing WordPress, this is not an Developing with WordPress topic.
 * Where did you find that file? In a theme or plugin? The reason I am asking is
   that if that code is supported here on this site (as a theme or plugin) then 
   I can direct you to the right place to raise that support topic.
 *  Thread Starter [janeric](https://wordpress.org/support/users/janeric/)
 * (@janeric)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/custom-shortcode-php-include-alt-text-for-images/#post-14835814)
 * I found it via the FTP. It’s located under the wp-content/themes/theme-name-child/
   includes
 * Thanks for your help!

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

The topic ‘custom shortcode php. – include alt-text for images’ is closed to new
replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [janeric](https://wordpress.org/support/users/janeric/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/custom-shortcode-php-include-alt-text-for-images/#post-14835814)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
