Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_last_posts() {
- global $post;
- $resultados = get_posts( array(
- 'numberposts' => 3,
- 'orderby' => 'date',
- 'order' => 'DESC',
- 'post_type' => 'product'
- ) );
- // print_r( $resultados );
- $html = '<div class="row">';
- if ( $resultados ) {
- foreach ( $resultados as $post ):
- setup_postdata( $post );
- $html .= '<div class="col-md-4">'.get_the_title().'</div>';
- endforeach;
- }
- $html .= '</div>';
- return $html;
- }
- function get_products_function( $atts ){
- return get_last_posts();
- }
- add_shortcode( 'get_products', 'get_products_function' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement