php - Wordpress loop return value have no html -
i add shortcode wordpress theme functions.php file have, problem. code "[logos]" return only:
form custom field, 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' ), ); // query $query = new wp_query( $args ); // 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?
as per above code, site must blank screen, there string parsing error. however, have changed code little bit. please, try this.
$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;"> ';
Comments
Post a Comment