RST – Shortcode Obras
// Add Shortcode
function obras_shortcode( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'posts' => '8',
'order' => 'desc',
),
$atts,
'obras'
);
// Query
$args = array(
'posts_per_page' => $atts['posts'],
'post_type' => 'obras',
'orderby' => 'ID',
'order' => $atts['order']
);
$the_query = new WP_Query($args);
$output = '';
while ($the_query->have_posts()) :
$the_query->the_post();
$output .= `<article class="portfolio-item col-12 col-sm-6 col-md-4 col-lg-3 pf-media pf-icons">
<div class="grid-inner">
<div class="portfolio-image">
<img src="` . esc_url(get_the_post_thumbnail_url(get_the_ID(), 'full')) . `" alt="` . get_the_title() . `">
<div class="bg-overlay">
<div class="bg-overlay-content dark" data-hover-animate="fadeIn">
<a href="#" class="overlay-trigger-icon bg-light text-dark" data-hover-animate="zoomIn" data-hover-animate-out="zoomOut" data-hover-speed="350"><i class="icon-line-ellipsis"></i></a>
</div>
<div class="bg-overlay-bg dark" data-hover-animate="fadeIn"></div>
</div>
</div>
<div class="portfolio-desc">
<h3><a href="#">` . get_the_title() . `</a></h3>
<span>` . get_the_excerpt() . `</span>
</div>
</div>
</article>`;
endwhile;
// Reset post data
wp_reset_postdata();
// Return code
return $output;
}
add_shortcode( 'obras', 'obras_shortcode' );