<?php
/* Template Name: Leader List Page */
get_header();
?>
<div style=”max-width:900px; margin:auto; padding:20px;”>
<h2>Leaders Directory</h2>
<p>Browse all leaders uploaded to the system.</p>
<?php
// Query all posts created by the Leader Upload Form
$leaders = new WP_Query(array(
‘post_type’ => ‘post’,
‘posts_per_page’ => -1,
‘meta_query’ => array(
array(
‘key’ => ‘leader_photo’,
‘compare’ => ‘EXISTS’
)
),
‘orderby’ => ‘date’,
‘order’ => ‘DESC’
));
if ($leaders->have_posts()) {
echo ‘<div style=”display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:20px;”>’;
while ($leaders->have_posts()) {
$leaders->the_post();
$photo = get_post_meta(get_the_ID(), ‘leader_photo’, true);
$video = get_post_meta(get_the_ID(), ‘leader_video’, true);
?>
<div style=”border:1px solid #ddd; padding:15px; border-radius:10px; background:#f9f9f9;”>
<?php if ($photo): ?>
<img src=”<?php echo esc_url($photo); ?>”
style=”width:100%; height:auto; border-radius:10px; margin-bottom:10px;”>
<?php endif; ?>
<h3><?php the_title(); ?></h3>
<p><?php echo wp_trim_words(get_the_content(), 25, ‘…’); ?></p>
<?php if ($video): ?>
<p><a href=”<?php echo esc_url($video); ?>” target=”_blank”>Watch Video</a></p>
<?php endif; ?>
<a href=”<?php the_permalink(); ?>”
style=”display:inline-block;margin-top:10px;padding:8px 12px;background:#0073aa;color:#fff;border-radius:5px;text-decoration:none;”>
View Full Profile
</a>
</div>
<?php
}
echo ‘</div>’;
} else {
echo ‘<p>No leaders found.</p>’;
}
wp_reset_postdata();
?>
</div>
<?php get_footer(); ?>
