Skip to content

Instantly share code, notes, and snippets.

View oliwa's full-sized avatar

Oliver Hulisz oliwa

View GitHub Profile
@oliwa
oliwa / functions.php
Created November 20, 2016 12:14
Wordpress: Remove Width and Height Attributes From Inserted Images
<?php
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
@oliwa
oliwa / snippet.php
Created November 17, 2016 12:19
Magnific Popupwith delayed opening, Cookie to switch off
<div id="advertisement" class="mfp-hide">
<div class="wrap group text-center">
<img src="http://placehold.it/800x600"/>
<p><a href="javascript:;" id="closeAd" class="button"><i class="fa fa-close"></i> Nicht mehr anzeigen</a></p>
</div>
</div>
<script src="<?php bloginfo('template_directory'); ?>/js/jquery.cookie.js"></script>
<script>
$(document).ready(function () {
@oliwa
oliwa / custom post type query.php
Created October 25, 2016 08:43
Custom Post Type Query (Events)
<?php
$today = date_i18n('Ymd');
$args = array(
'post_type' => 'events',
'posts_per_page' => -1,
'meta_key' => 'event_date',
'meta_compare' => '>=',
'meta_value' => $today,
'orderby' => 'meta_value',
'order' => 'asc',
@oliwa
oliwa / os-body-class.php
Last active December 5, 2018 07:08
Add OS to Body Class
<?php
function mv_browser_body_class($classes) {
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
if($is_lynx) $classes[] = 'lynx';
elseif($is_gecko) $classes[] = 'gecko';
elseif($is_opera) $classes[] = 'opera';
elseif($is_NS4) $classes[] = 'ns4';
elseif($is_safari) $classes[] = 'safari';
elseif($is_chrome) $classes[] = 'chrome';
@oliwa
oliwa / snippet.php
Last active December 5, 2018 07:08
ACF Repeater FAQ
<div id="container">
<?php if( have_rows('projektinfos') ): ?>
<?php while ( have_rows('faq') ) : the_row(); ?>
<h2 class="headline"><?php the_sub_field('faq-head'); ?></h2>
<div class="copytext"><?php the_sub_field('faq-copy'); ?></div>
<?php endwhile; ?>
<?php else : ?>
<p><mark>Noch keine Repeater Felder angegeben</mark></p>
@oliwa
oliwa / fa-icons.css
Last active April 23, 2019 11:17
Insert FA Icon with Pseudo Attributes
ul li {
position:relative;
padding: .2em 0 .2em 1em;
margin: 0;
}
ul li:before {
position: absolute;
top: .4em;
left: 0;
content: '\f054';
@oliwa
oliwa / terms.php
Created July 25, 2016 08:03
Get Terms from a Custom Post Type: 2 Methods
<!-- Get Taxonomy Title from active Taxonomy -->
<?php // https://wordpress.org/support/topic/taxonomy-title-output ?>
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?>
<!-- List all Taxonomy Terms that are assigned -->
<?php // https://codex.wordpress.org/Function_Reference/the_terms ?>
<?php the_terms( $post->ID, 'glossary-categories', '', ', ', ''); ?>
@oliwa
oliwa / custom-count.css
Created July 11, 2016 12:45
Custom Counter for Ordered Lists
ol.custom-counter {
margin: 1em 0 1em 2em;
padding: 0;
list-style-type: none;
}
ol.custom-counter li {
position: relative;
counter-increment: step-counter;
margin-bottom: .5em;
}
@oliwa
oliwa / functions.php
Created June 17, 2016 15:52
Output blog ID in body tag
<?php
// Add site-id class to body functions.php
add_filter('body_class', 'multisite_body_classes');
function multisite_body_classes($classes) {
$id = get_current_blog_id();
$classes[] = 'site-id-'.$id;
return $classes;
}
@oliwa
oliwa / google-map.php
Created June 3, 2016 07:53
Google Map
<div id="map" style="height: 420px; width: 100%;"></div>
<script>
function initMap() {
var mapDiv = document.getElementById('map');
var myLatLng = {lat: 52.251458, lng: -0.118886};
var map = new google.maps.Map(mapDiv, {
center: myLatLng,
zoom: 15
});