Skip to content

Instantly share code, notes, and snippets.

View oliwa's full-sized avatar

Oliver Hulisz oliwa

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / show-hide-repeater-field.php
Created February 4, 2017 10:50
Show Hide for a repeater field
<?php if( have_rows('show_hide_repeater') ): ?>
<h2><?php the_field('show_hide_repeater_headline'); ?></h2>
<?php while ( have_rows('show_hide_repeater') ) : the_row(); ?>
<div class="open-close">
<a class="infobox-button close" href="#">
<h3 title="Projekt öffnen/schließen"><?php the_sub_field('show_hide_title'); ?></h3>
<span class="more"><i title="Projekt öffnen" class="fa fa-chevron-down"></i></span>
<span class="hide"><i title="Projekt schließen" class="fa fa-chevron-up"></i></span>
</a>
@oliwa
oliwa / repeater.php
Created February 21, 2017 15:07
Repeater Field with Gallery
<?php if( have_rows('mede_events') ): while ( have_rows('mede_events') ) : the_row(); ?>
<hr/>
<h2><i class="fa fa-flag"></i> <?php the_sub_field('med_event_title'); ?></h2>
<?php the_sub_field('med_event_copy'); ?>
<?php $images = get_sub_field('med_event_gallery'); ?>
<?php if( $images ): foreach( $images as $image ): ?>
<a href="<?php echo $image['url']; ?>">