Skip to content

Instantly share code, notes, and snippets.

View mikeoberdick's full-sized avatar

Mike Oberdick mikeoberdick

View GitHub Profile
@mikeoberdick
mikeoberdick / bootstrap-dropdown-menu-offset.js
Created May 5, 2024 15:52
Bootstrap 5 .dropdown-menu data-offset for drop down menus under nav links that use underlines on hover
//ADD DATA OFFSET TO THE MAIN NAV DROPDOWN MENU
$(".dropdown-menu").attr('data-bs-offset', '10,20');
@mikeoberdick
mikeoberdick / no-page-reload-on-same-page-jump-link.js
Created May 5, 2024 15:51
Don't reload page when clicking a jump link from nav menu that references a place on the same page
@mikeoberdick
mikeoberdick / url-based-accordion.js
Created April 5, 2024 10:09
Open up a bootstrap accordion/collapse using attribute from url following # symbol
if (window.location.href.indexOf("requirements") > -1 && window.location.href.indexOf("#") > -1) {
//get the text after the #
var tab = window.location.href.split('#')[1];
//if text is highResidency
if (tab == 'highResidency') {
$('#collapse-content-0').show();
} else {
$('#collapse-content-1').show();
}
}
@mikeoberdick
mikeoberdick / filter_archive_query.php
Created July 6, 2023 12:07
Filter the query on the events archive to only show upcoming events
function show_upcoming_events( $query ) {
if( is_admin() ) {
return $query;
}
if ( ( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'event' ) ) {
$today = date('Y-m-d H:i:s', strtotime("-1 days"));
$meta_query = array(
@mikeoberdick
mikeoberdick / style_hero_dots_for_slick_slider.scss
Created March 19, 2023 20:29
Default style for slick slider hero dots #heroDots
#heroDots {
position: absolute;
width: 100%;
bottom: 50px;
left: 50%;
transform: translateX(-50%);
.slick-dots {
list-style: none;
padding-left: 0;
display: flex;
@mikeoberdick
mikeoberdick / wordpress_responsive_srcset.php
Created March 10, 2023 21:26
Use the responsive srcset functionality with ACF.
<?php $image = get_field('about_img');
if( $image ) {
echo wp_get_attachment_image( $image, 'full', "", array( "class" => "img-fluid" ) );
} ?>
@mikeoberdick
mikeoberdick / trimmed_text.php
Last active March 19, 2023 16:40
PHP for creating a custom excerpt using the wp_trim function
<p><?php echo wp_trim_words( get_field('content_english'), 20, '...<a href = "' . get_permalink() . '" class = "teal fw-bold">Read More</a></p>' ) . '</p>'; ?>
@mikeoberdick
mikeoberdick / conditional_video.php
Created March 6, 2023 02:19
Conditional video script for either an ACF file or an oEmbed (YouTube video)
<?php if ($sectionTwo['video_type'] == 'file') { ?>
<?php $video = $sectionTwo['video_file']; ?>
<video class = "w-100" controls poster="<?php echo get_stylesheet_directory_uri() . '/img/poster.jpg'; ?>">
<source src="<?php echo $sectionTwo['vide_file]; ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
<?php } else { ?>
<div class="embed-container">
<?php echo $sectionTwo['youtube_video']; ?>
</div><!-- .embed-container -->
@mikeoberdick
mikeoberdick / back_to_previous_page.php
Last active February 29, 2024 14:17
Create a button to go back to the previous page with referrer checks
<?php $referrer = $_SERVER['HTTP_REFERER']; ?>
<?php if (str_contains($referrer, 'simplify-the-market-blog')) {
$href = "javascript:history.back()";
else {
$href = "/simplify-the-market-blog";
} ?>
<a href="<?php echo $href; ?>" class="btn"><i class="la la-angle-left"></i> Back</a>
@mikeoberdick
mikeoberdick / style.css
Last active February 11, 2023 12:29 — forked from djrmom/readme.txt
facetwp radio styled as buttons
.facetwp-radio {
background-image: none;
background-color: gray;
padding: 5px;
display: inline-block;
margin: 5px;
}
.facetwp-radio.checked {
background-image: none;