Skip to content

Instantly share code, notes, and snippets.

@galengidman
galengidman / functions.php
Last active June 6, 2021 12:10
Adding Static Menu Items to wp_nav_menu()
<?php
function my_nav_wrap() {
// default value of 'items_wrap' is <ul id="%1$s" class="%2$s">%3$s</ul>'
// open the <ul>, set 'menu_class' and 'menu_id' values
$wrap = '<ul id="%1$s" class="%2$s">';
// get nav items as configured in /wp-admin/
$wrap .= '%3$s';
@galengidman
galengidman / functions.php
Last active August 29, 2015 13:57
register CTP with Dashicon
<?php
register_post_type('slide', array(
'label' => 'Slides',
'menu_icon' => 'dashicons-slides'
));
@galengidman
galengidman / index.php
Created March 28, 2014 19:10
get ACF image size URL by image object
<?php
// first, get the image object returned by ACF
$image_object = get_field('my_image_field');
// and the image size you want to return
$image_size = 'thumbnail';
// now, we'll exctract the image URL from $image_object
$image_url = $image_object['sizes'][$image_size];
@galengidman
galengidman / index.php
Created March 28, 2014 19:01
get ACF image size URL by ID
<?php
// first, get the image ID returned by ACF
$image_id = get_field('my_image_field');
// and the image size you want to return
$image_size = 'thumbnail';
// use wp_get_attachment_image_src to return an array containing the image
// we'll pass in the $image_id in the first parameter
@galengidman
galengidman / index.html
Created March 28, 2014 18:56
.page-row markup for easy styling
<header class="page-row">
<!-- apply your styles to me -->
<div class="header-inner">
<h1>Site Title</h1>
</div>
</header>
@galengidman
galengidman / index.html
Last active November 26, 2020 17:36
`display: table` sticky footer trick
<header class="page-row">
<h1>Site Title</h1>
</header>
<main class="page-row page-row-expanded">
<p>Page content goes here.</p>
</main>
<footer class="page-row">
<p>Copyright, blah blah blah.</p>
@galengidman
galengidman / menu.html
Created March 28, 2014 15:43
Statamic Menu
<ul id="menu" class="menu">
{{ if menu }}
{{ menu }}
<li{{ if submenu }} class="has-submenu"{{ endif }}>
<a href="{{ url }}"{{ if target }} target="{{ target }}"{{ endif }}>{{ name }}</a>
{{ if submenu }}
<ul class="submenu">
{{ submenu }}
<li><a href="{{ url }}"{{ if target }} target="{{ target }}"{{ endif }}>{{ name }}</a></li>
@galengidman
galengidman / text-inputs.css
Created March 18, 2014 16:11
Elements to target to style text inputs.
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="url"],
textarea {
/* styles */
}
function classIfOffset(element, class, offset) {
var scroll = $(window).scrollTop();
if (scroll > offset) {
element.addClass(class);
} else {
element.removeClass(class);
}
}
@galengidman
galengidman / gist:7058364
Last active December 25, 2015 23:39
Returns the page title of the blog posts page as set in Settings → Reading.
function get_posts_page_title() {
if (get_option('show_on_front') == 'page') {
return get_the_title(get_option('page_for_posts'));
}
return false;
}