Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Oberdick mikeoberdick

View GitHub Profile
@mikeoberdick
mikeoberdick / plus_to_minus_css_animation.scss
Created Jun 2, 2021
Morph a plus icon into a minus icon for accordians and menus
View plus_to_minus_css_animation.scss
/*
<div class = "plus-to-minus">
<span></span>
<span></span>
</div>
*/
.question-container {
.plus-to-minus {
width: 50px;
@mikeoberdick
mikeoberdick / parallax.css
Created Jun 1, 2021
Parallax effect for background images
View parallax.css
<section id="sectionFour">
<?php $img = $four['full_size_image']; ?>
<div class="parallax" style = "background: url('<?php echo $img['url']; ?>');"></div>
</section><!-- #sectionFour -->
.parallax {
min-height: 500px;
background-attachment: fixed !important;
background-position: center !important;
background-repeat: no-repeat !important;
@mikeoberdick
mikeoberdick / sort_posts_by_most_popular.php
Last active May 16, 2021
Track post views and then sort by post views in order to display most read posts
View sort_posts_by_most_popular.php
@mikeoberdick
mikeoberdick / dropdown_by_post_type_in_ninja_forms.php
Created May 16, 2021
Create a drop down list that pulls a custom post type such as events in Ninja Forms
View dropdown_by_post_type_in_ninja_forms.php
add_filter( 'ninja_forms_render_default_value', 'nf_hidden_field_values', 10, 3 );
// Populate event names for dropdown
add_filter( 'ninja_forms_render_options', function($options,$field_settings){
if( $field_settings['key'] == 'event_names' ) {
$args = array(
'post_type' => 'event',
'posts_per_page' => -1,
'post_status' => 'publish'
);
$the_query = new WP_Query( $args );
@mikeoberdick
mikeoberdick / default_pagination.html
Created May 5, 2021
pagination for default query
View default_pagination.html
<div class="pagination">
<?php
echo paginate_links( array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'total' => $qry->max_num_pages,
'current' => max( 1, get_query_var( 'paged' ) ),
'format' => '?paged=%#%',
'show_all' => false,
'end_size' => 2,
'mid_size' => 1,
@mikeoberdick
mikeoberdick / custom_excerpt_for_acf_fields.php
Created May 2, 2021
Create a custom excerpt from ACF field
View custom_excerpt_for_acf_fields.php
//Custom excerpts for ACF fields
function wp_trim_excerpt_modified($text, $content_length = 55, $remove_breaks = false) {
if ( '' != $text ) {
$text = strip_shortcodes( $text );
$text = excerpt_remove_blocks( $text );
$text = apply_filters( 'the_content', $text );
$text = str_replace(']]>', ']]&gt;', $text);
$num_words = $content_length;
$more = $excerpt_more ? $excerpt_more : null;
if ( null === $more ) {
@mikeoberdick
mikeoberdick / shopify_run_iteration_on_loop.liquid
Created Apr 28, 2021
Use the following when adding iteration based content in shopify
View shopify_run_iteration_on_loop.liquid
{% for block in section.blocks %}
{% assign count = 1 %}
data-aos="{% if count == 1 or count == 3 %}fade-up-right{% else %}}fade-up-left{% endif %}"
{% assign count = count | plus: 1 %}
{% endfor %}
@mikeoberdick
mikeoberdick / set_all_elements_match_widest.js
Created Apr 14, 2021
function for setting a set of elements to match the widest in the set
View set_all_elements_match_widest.js
$.fn.widest = function() {
return this.length ? this.width(Math.max.apply(Math, this.map(function() {
return $(this).width();
}))) : this;
};
@mikeoberdick
mikeoberdick / transparent_bg_drop_shadow.css
Last active Apr 29, 2021
Drop shadow CSS for png image with transparent background
View transparent_bg_drop_shadow.css
-webkit-filter: drop-shadow(5px 5px 5px rgba(0,0,0,.75));
filter: drop-shadow(5px 5px 5px rgba(0,0,0,.75));
@mikeoberdick
mikeoberdick / pull_ninja_form_field_values_on_submit.js
Created Feb 1, 2021
Dynamically grab field values from Ninja Form fields on submit
View pull_ninja_form_field_values_on_submit.js
<script>
var getQuoteFields = Marionette.Object.extend( {
initialize: function() {
this.listenTo( Backbone.Radio.channel( 'forms' ), 'submit:response', this.actionSubmit );
},
actionSubmit: function( response ) {
$sqFootage = response.data['fields'][15]['value'];
//Remove the hypens and replace with spaces
$county = response.data['fields'][10]['value'].replace(/-/g, " ");
jQuery('#squareFootage').text($sqFootage);