Skip to content

Instantly share code, notes, and snippets.

@eclarrrk
eclarrrk / wp-get-image-URL-w-size.php
Last active January 8, 2019 21:02
Get the URL for a specific size of an attachment image
<?php
$size = 'large';
$image_ID = get_field('field_name'); // when using ACF, choose 'Image ID' for return value
$image_array = wp_get_attachment_image_src($image_ID, $size);
$image_URL = $image_array[0];
echo $image_URL;
?>
@eclarrrk
eclarrrk / rrr-form-styles.scss
Created February 11, 2019 14:56
RRR form style tweaks for M6
.forms li input, .forms li textarea {
font-size: 16px; // was 15px
padding: .66em 1em; // was 15px
}
form#form-vlc-race-registration label.field_label {
margin: 1em 0 0 0; // was 16px 0 3px 0
}
form#form-vlc-race-registration h2 {
@eclarrrk
eclarrrk / functions.php
Last active February 20, 2019 18:28
Wide and Full-width Gutenberg block options
<?php
// Register support for Gutenberg wide images in your theme
function mytheme_setup() {
add_theme_support( 'align-wide' );
}
add_action( 'after_setup_theme', 'mytheme_setup' );
@eclarrrk
eclarrrk / responsive-font-size-mixin.scss
Last active April 14, 2022 20:07
Responsive Font Size Sass Mixin
// settings
$remBase: 16; //set base font size. unitless value in pixels.
$widthMin: 480; //set small breakpoint. unitless value in pixels.
$widthMax: 1024; //set large breakpoint. unitless value in pixels.
@mixin font-size($valueMin, $valueMax) {
// turn mixin parameters into rem value.
$fontMin: $valueMin * $remBase;
$fontMax: $valueMax * $remBase;
@eclarrrk
eclarrrk / functions.php
Last active March 14, 2019 18:35
Style the WordPress login page
<?php
// Add styles to the login page
function login_css() { ?>
<style type="text/css">
/* Change the WP logo to your own */
#login h1 a, .login h1 a {
background-image: url('<?php echo get_stylesheet_directory_uri(); ?>/path/to/logo.png');
height: 150px;
width: 150px;
@eclarrrk
eclarrrk / get-gravity-forms-entries.php
Last active May 29, 2022 22:46
Display Gravity Form entries into WordPress page template
<?php
/*
Official Gravity Forms documentation on get_entries() found here:
https://docs.gravityforms.com/api-functions/#get-entries
*/
/* Gravity Form ID. */
$form_id = '20';
/* Sorting options avalable but left blank for simplicity. */
@eclarrrk
eclarrrk / year-current.php
Last active March 27, 2020 17:48
Use JS to get current year
//using PHP
<?php echo date('Y'); ?>
// using javascript
<span id="year"></span>
<script>
document.getElementById("year").innerHTML = new Date().getFullYear();
</script>
@eclarrrk
eclarrrk / change-font-size-by-headline-length.css
Last active January 26, 2022 15:25
Set headline font size based on the length of a headline
/* This is the default headline size. */
.headline,
.headline--normal {
font-size: 2em;
}
/* When the headline is shorter, make the font-size larger */
.headline--short {
font-size: 2.5em;
}
/* When the headline is longer, make the font-size smaller */
@eclarrrk
eclarrrk / equal-height-image-rows.php
Last active July 1, 2020 20:15
Using the ACF Repeater field to make all images in a row the same height regardless of dimensions or the quantity of images per row
<?php if( have_rows('gallery') ): ?>
<div class="gallery">
<?php while( have_rows('gallery') ): the_row(); ?>
<div class="gallery__row" style="display: flex;">
<?php if( have_rows('image_row') ): ?>
<?php while( have_rows('image_row') ): the_row(); ?>
@eclarrrk
eclarrrk / display-file-contents.html
Created September 1, 2020 17:48
Display the contents of a text-based file on a page using jQuery
<p>Get the contents of <code>/wp-content/themes/webguard-ra-theme/sass/typography/_font-size.scss</code></p>
<pre class="has-small-font-size" id="myelement"></pre>
Using this code:
<pre class="has-small-font-size">
$( document ).ready(function() {
jQuery.get("/wp-content/themes/webguard-ra-theme/sass/typography/_font-size.scss", undefined, function(data) {
$('#myelement').append(data);
}, "html");
});</pre>