Skip to content

Instantly share code, notes, and snippets.

View leanneromak's full-sized avatar

Leanne Romak leanneromak

View GitHub Profile
@leanneromak
leanneromak / .php
Created August 4, 2015 21:07
WP Query for events posts with upcoming dates
<?php
$current_date = date(Ymd);
$event_args = array(
'post_type' => 'event_post_type',
'meta_query' => array(
array(
'key' => 'date_field',
'value' => $current_date,
'compare' => '>='
)
@leanneromak
leanneromak / .php
Created August 5, 2015 14:06
Show a field if either fields are true
<?php if( get_field(‘field_name’) || get_field(‘field_name_two’) ): ?>
@leanneromak
leanneromak / .php
Created August 5, 2015 14:10
Unordered list format for field
<div class="class_name" >
<ul><?php foreach(get_field('field_name') as $something) {
echo ‘<li>’.$something.’</li>’;
} ?></ul><? endif; ?>
</div>
<?php
/*
* Displaying single value
*/
?>
<p>Posted on: <?php the_field('date_picker'); ?></p>
<?php
@leanneromak
leanneromak / .php
Last active August 29, 2015 14:26
php conditional for post class
<?php if( is_single( 'field_name1' ) ): ?>
//do something
<?php elseif( is_single( 'fieldname2' ) ): ?>
//do something else
<?php elseif( is_single( '' ) ): ?>
//this is the default
<?php endif; ?>
@leanneromak
leanneromak / taxonomy_term_title.php
Created August 11, 2015 16:51
Get Taxomony term for Title
<h1><?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?></h1>
@leanneromak
leanneromak / editor-custom-role.php
Last active December 10, 2015 17:27
Editor user role for functions.php
/**
* control editor role
*/
$role = get_role('editor');
$role->add_cap('edit_theme_options');
function custom_admin_menu() {
$user = new WP_User(get_current_user_id());
@leanneromak
leanneromak / vcf-add-to-functions.php
Created December 10, 2015 22:27
allow .vcf upload to media library (v-cards)
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
// add your extension to the array
$existing_mimes['vcf'] = 'text/x-vcard';
return $existing_mimes;
}
@leanneromak
leanneromak / hideshow.html
Last active February 12, 2016 20:32
hide/show divs on desktop/mobile with CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>hide and show</title>
<style type="text/css">
#mobile-only {
display:none;
}
@leanneromak
leanneromak / WP display categories
Created January 29, 2018 22:06
WP display categories as list with no link
<span class="pp-data"> Category: </span>
<?php $terms = get_the_terms($post->ID, 'category-pp');
$count = count($terms);
if ( $count > 0 ){
foreach ( $terms as $term ) {
echo $term->name;
}
}
?>