Interpolating variables and multiline markup in PHP

Various methods on writing and returning variables within markup in PHP
#php #html

Dynamic Scroll Based Classes

Here is a super useful snippet for dynamically updating the body's class based on scroll position in the browser.
#javascript #css

How to embed partials in Markdown Using Hugo

It's not often easy to intersperse markup in markdown. Hugo makes this easy with the use of shortcodes.
#hugo #markdown

Click to scroll to the next section

Create dynamic buttons that scroll to the next section on the page

Offset a WordPress loop with pagination

Understanding how pagination works in WP is hard. Offsetting loops with pagination can be harder. Luckily, I went through all this trial and error so you don't have to! Copy and paste (almost) guaranteed.

Netlify x Hugo : using custom headers for better caching

Netlify turns off caching by default. Learn how to cache assets using Hugo and Netlify's custom headers.
#api #hugo

Load the next page using ajax

Simply no plugin needed.
#jquery #wordpress

Get the *actual* page ID in WordPress archives

Useful if you want to retrieve specific page ID's from an archive template

List a post's terms without permalinks

Easily get a post's terms and list them with separators.

Check if a device is a touchscreen

Sometimes it's useful to know if the device a user is visiting on is a touchscreen or not. This is because touchscreens don't generally render things like hover states.

Check if background-attachment:fixed is supported


Check if the_content() has content


Responsive CSS circles


Simple Sticky Header

A quick and easy way to make a header sticky using jquery
#css #jquery

Output data to multiple elements with one loop

#php #wordpress

Alter a query in WordPress with pre_get_posts

You can alter multiple queries with ease using this single function.

Shorthand if/else statements in PHP & JS

#php #javascript

Quickly access a page's object in WordPress


Centering elements with CSS

You wouldn't think it, but centering elements with CSS has got to be one of the most finicky things ever.

Style form placeholders

Browser hacks incoming.

Load Instagram posts using ajax

Load instagram posts without a developer account.
#jquery #api

Responsive images in WordPress with srcset

srcset is handled extremely well by WordPress. I use this tag for almost all images I serve on a page (even backgrounds).