Tạo element news trên flatsome

<?php function news_ux_builder_element(){ add_ux_builder_shortcode(‘inno_news’, array( ‘name’ => __(‘News Element’), ‘category’ => __(‘Content’), ‘priority’ => 1, ‘options’ => array( ‘text’ => array( ‘type’ => ‘textfield’, ‘heading’ => ‘Category’, ‘default’ => , ‘auto_focus’ => true, ), ), )); } add_action(‘ux_builder_setup’, ‘news_ux_builder_element’); function inno_news_func($atts){ extract(shortcode_atts(array( ‘text’ => , ), $atts)); ob_start(); //echo ‘

‘.$text.’


‘; $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 5, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, ‘terms’ => $text ) ) ); $news = new WP_Query( $args ); //echo $text; if( $news->have_posts() ) : ?> <ul class=”boxnews“> <?php $i=1; while( $news->have_posts() ) : $news->the_post(); if($i==1){ ?> <div class=”row“> <div class=”col medium-5 small-12 large-5″> <div class=”colinner“> <div class=”img hashover x mdx lgx y mdy lgy“> <a href=”<?php echo get_the_permalink(); ?>”> <div class=”imginner dark“> <img width=”600″ height=”400″ src=”<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID)); ?>” class=”attachmentlarge sizelargealt=””> </div> </a> </div> </div> </div> <div class=”col medium-7 small-12 large-7″> <div class=”colinner“> <a href=”<?php echo get_the_permalink(); ?>”><h2 class=”uppercase“><?php echo get_the_title(); ?></h2></a> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat…<a href=”<?php echo get_the_permalink(); ?>”>xem thêm</a></p> <h3>Xem thêm: </h3> <?php }else{ ?> <li><a class=”normalhref=”<?php echo get_the_permalink(); ?>”><h5><?php echo get_the_title(); ?></h5> </a></li> <?php } ?> <?php $i++; endwhile; wp_reset_postdata(); ?> </div> </div> </div> </ul> <?php else : esc_html_e( ‘No news display!’, ‘innocom‘ ); endif; return ob_get_clean(); } add_shortcode(‘inno_news‘, ‘inno_news_func‘); ?>

Leave a Reply

Your email address will not be published. Required fields are marked *