Quick Shortcode
Wed Dec 18 2024 06:45:55 GMT+0000 (Coordinated Universal Time)
Saved by
@omnixima
#javascript
// Shortcode [fellow_intern type='']
function fellow_intern ( $atts, $content = null) {
$today = date('Ymd');
$atts = shortcode_atts(
array(
'type' => '',
'number' => '-1',
),
$atts,
'fellow_intern'
);
$args = array(
'post_type' => 'fellow-intern',
'posts_per_page' => -1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
);
if( !empty( $atts['type'] ) ) {
$args['tax_query'] = array(
array(
'taxonomy' => 'fellow-type',
'field' => 'slug',
'terms' => $atts['type'],
)
);
}
$fellow_query = new WP_Query($args);
ob_start();
if($fellow_query->have_posts()) { ?>
<div class="fellows-wrapper">
<?php
while ($fellow_query->have_posts()) {
$fellow_query->the_post(); ?>
<div class="fellow-inner">
<!-- Thumbnail -->
<div class="fellow-img">
<?php if ( has_post_thumbnail() ) { the_post_thumbnail('full'); } ?>
</div>
<div class="fellow-content">
<!-- Title -->
<h3><?php echo the_title(); ?></h3>
<!-- Details -->
<div class="fellow-details">
<?php echo the_content(); ?>
</div>
</div>
</div>
<?php }
wp_reset_postdata();
?>
</div>
<?php
} else { ?>
<div>No fellows found</div>
<?php }
return ob_get_clean();
}
add_shortcode('fellow_intern', 'fellow_intern');
content_copyCOPY
Comments