<div class="blog-filters">
<div class="select-container">
<select id="selectMe">
<option value="all-future">Topic</option>
<option value="business-management">Business management</option>
<option value="financials">Financials</option>
<option value="project-management">Project management</option>
<option value="sales-marketing">Sales and Marketing</option>
<option value="virtual-training">Virtual Training</option>
</select>
</div>
</div>
<div class="wp-block-group alignfull">
<div class="wp-block-group__inner-container">
<div class="wp-block-group tabbed-content all-future">
<div class="wp-block-group__inner-container">
<?php
// All future webinars
// get today's date
$today = date( 'Y-m-d' );
// get posts
$futureposts_all = get_posts(array(
'post_type' => 'webinar',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'date_and_time',
'value' => $today,
'compare' => '>='
)
),
));
//var_dump( $futureposts_buisness );
if( $futureposts_all ) : ?>
<div class="row">
<?php foreach( $futureposts_all as $post ) : setup_postdata( $post ); ?>
<div class="col-md-4">
<div id="block_5ed527ab633fb" class="wp-block-classic align block-desktop">
<div style="height: 600px !important;">
<a class="aug20 card" style="cursor: pointer;"><p></p>
<div class="card-image">
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID), 'thumbnail' ); ?>
<img src="<?php echo $url ?>" alt="Featured image of this webinar"/>
</div>
<div class="card-text">
<h3>
<?php
$seo_friendly_title = get_field( 'seo_friendly_title' );
if ( $seo_friendly_title ) {
echo $seo_friendly_title;
} else {
the_title();
}
?>
</h3>
<p class="date"><?php echo the_field( 'date_and_time' ); ?> CDT</p>
<p><?php the_excerpt(); ?></p>
</div>
</a>
<a class="card" style="cursor: pointer;"></a>
<p class="center-mob"><a class="plumb-button navy-ghost" href="<?php the_permalink(); ?>">Register</a> </p>
</div>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php endforeach; ?>
</div> <!-- End ROW -->
<?php else: ?>
<p>No upcoming webinars are scheduled</p>
<?php endif; ?>
</div>
</div><!-- END All future webinars -->
jQuery(document).ready(function($) {
$("#selectMe").change(function() {
$(this).find("option:selected").each(function(){
if($(this).attr("value")=="all-future"){
$(".tabbed-content").not(".all-future").hide();
$(".all-future").show();
}else if($(this).attr("value")=="business-management"){
$(".tabbed-content").not(".buisness-future").hide();
$(".buisness-future").show();
}else if($(this).attr("value")=="financials"){
$(".tabbed-content").not(".financial-future").hide();
$(".financial-future").show();
}else if($(this).attr("value")=="project-management"){
$(".tabbed-content").not(".project-future").hide();
$(".project-future").show();
}else if($(this).attr("value")=="sales-marketing"){
$(".tabbed-content").not(".sales-future").hide();
$(".sales-future").show();
}else if($(this).attr("value")=="virtual-training"){
$(".tabbed-content").not(".virtual-future").hide();
$(".virtual-future").show();
}else{
$(".tabbed-content").hide();
}
});
}).change();
});
ASKER
jQuery(document).ready(function($) {
$("#selectMe option[value=all-future]").attr('selected', 'selected');
$("#selectMe").change();
});
<script>
jQuery(function($) {
$("#selectMe").change(function() {
var optionsToClasses = {
"all-future": ".all-future",
"business-management": ".buisness-future",
"financials": ".financial-future",
"project-management": ".project-future",
"sales-marketing", ".sales-future",
"virtual-training": ".virtual-future"
}
$(".tabbed-content").hide();
$("option:selected", this).each(function(){
$(optionsToClasses[$(this).val()]).show();
});
}).change();
});
</script>
<option value="all-future" selected>Topic</option>
It shows the all-future content on load (again this could have been done on page render by defaulting the .all-future tabbed content to a visible state.ASKER
/* -- Future Webinars --*/
jQuery(document).ready(function($) {
$("#selectMe option[value=all-future]").attr('selected', 'selected');
$("#selectMe").change();
});
jQuery(document).ready(function($) {
$("#selectMe").change(function() {
$(this).find("option:selected").each(function(){
if($(this).attr("value")=="all-future"){
$(".tabbed-content").not(".all-future").hide();
$(".all-future").show();
}else if($(this).attr("value")=="business-management"){
$(".tabbed-content").not(".business-future").hide();
$(".business-future").show();
}else if($(this).attr("value")=="financials"){
$(".tabbed-content").not(".financial-future").hide();
$(".financial-future").show();
}else if($(this).attr("value")=="project-management"){
$(".tabbed-content").not(".project-future").hide();
$(".project-future").show();
}else if($(this).attr("value")=="sales-marketing"){
$(".tabbed-content").not(".sales-future").hide();
$(".sales-future").show();
}else if($(this).attr("value")=="virtual-training"){
$(".tabbed-content").not(".virtual-future").hide();
$(".virtual-future").show();
}else{
$(".tabbed-content").hide();
}
});
}).change();
});
/* -- Past webinars -- */
jQuery(document).ready(function($) {
$("#selectMePast option[value=all-past]").attr('selected', 'selected');
$("#selectMePast").change();
});
jQuery(document).ready(function($) {
$("#selectMePast").change(function() {
$(this).find("option:selected").each(function(){
if($(this).attr("value")=="all-past"){
$(".tabbed-content").not(".all-past").hide();
$(".all-past").show();
}else if($(this).attr("value")=="business-management"){
$(".tabbed-content").not(".business-past").hide();
$(".business-past").show();
}else if($(this).attr("value")=="financials"){
$(".tabbed-content").not(".financial-past").hide();
$(".financial-past").show();
}else if($(this).attr("value")=="project-management"){
$(".tabbed-content").not(".project-past").hide();
$(".project-past").show();
}else if($(this).attr("value")=="sales-marketing"){
$(".tabbed-content").not(".sales-past").hide();
$(".sales-past").show();
}else if($(this).attr("value")=="virtual-training"){
$(".tabbed-content").not(".virtual-past").hide();
$(".virtual-past").show();
}else{
$(".tabbed-content").hide();
}
});
}).change();
});
ASKER
/* -- Future Webinars --*/
jQuery(function($) {
$(function() {
const selectMe = document.getElementById('selectMe');
// Select default value (although this could have been done by
// adding the selected attribute to the 'all-future' option above)
selectMe.value = 'all-future';
// Just show it on page load
$(".all-future").show();
$("#selectMe").change(function() {
// Get the selected value
const val = this.value;
// Hide all
$('.tabbed-content').hide();
// If a value is selected then show it
if (val) {
$('.' + val).show();
}
})
});
});
<script>
jQuery(function($) {
const handler = function() {
var optionsToClasses = {
"all-future": ".all-future",
"business-management": ".buisness-future",
"financials": ".financial-future",
"project-management": ".project-future",
"sales-marketing", ".sales-future",
"virtual-training": ".virtual-future"
}
$(".tabbed-content").hide();
$("select[id^='selectMe'] option:selected").each(function() {
$(optionsToClasses[$(this).val()]).show();
})
}
$("select[id^='selectMe']").change(handler);
handler(); // run it at page load
});
</script>
ASKER
ASKER
debugger;
alert("reached");// or use an alert
jQuery(document).ready(f..
Open in new window