I add shortcode to WordPress theme functions.php file but have, a problem. This code “[logos]” return only:

http://mydomain.pl/wp-content/uploads/2017/04/file1.pnghttp://mydomain.pl/wp-content/uploads/2017/04/file2.pnghttp://mydomain.pl/wp-content/uploads/2017/04/file3.pnghttp://mydomain.pl/wp-content/uploads/2017/04/file4.png

form custom field, but do not return HTML code.

                    function subscribe_link_shortcode() {

                      $html =

                      '<div>
                                    <h3>' . $mastertitle . '</h3>
                                    <div class="cmsms_clients_slider" id="cmsms_clients_slider553e45022ef2d">

                                      <script>
                                        jQuery(document).ready(function() {
                                          jQuery('#cmsms_clients_slider553e45022ef2d').cmsmsClientsSlider({
                                            sliderBlock : '#cmsms_clients_slider553e45022ef2d',
                                            sliderItems : '.cmsms_clients_items',
                                            clientsInPage : 5
                                          });
                                        });
                                      </script>

                                      <a href="javascript:void(0);" class="cmsms_clients_slider_arrow_prev"></a>
                                      <a href="javascript:void(0);" class="cmsms_clients_slider_arrow_next"></a>
                                      <ul class="cmsms_clients_items" style="width: 1161px; margin-left: 0px;">
                                      ';



                                      // WP_Query arguments
                                $args = array(
                                  'post_type'              => array( 'logo' ),
                                );

                                // The Query
                                $query = new WP_Query( $args );

                                // The Loop
                                if ( $query->have_posts() ) {
                                  while ( $query->have_posts() ) {
                                    $query->the_post();


                                    $html .= '<li class="cmsms_clients_item" style="width: 232px;">
                                      <img width="165" src="' .the_field('obrazek_logo'). '" class="cmsms_clients_img cmsms_animated" style="height: auto;">
                                    </li>';


                                  }
                                } else {
                                  // no posts found
                                }

                                // Restore original Post Data
                                wp_reset_postdata();




                                $html .= '
                                      </ul>
                                    </div>
                                  </div>';




                         ;

                      return $html;


                  }
                  add_shortcode('logos', 'subscribe_link_shortcode');

Anyone know why?

Read more here: WordPress loop return value have no html


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: