How to Add Retina Images to HubSpot Email and Page Templates

Category: Code Snippets

HubSpot CMS handles responsive images by default by creating different image sizes for different screen widths (using srcset). But with retina display images, you want to load higher resolution images and scale them down to 100%. Thankfully you can add ?noresize to the end of your image source to disable this dynamic resizing. In the… Read more »

Continue Reading

How to Fire a jQuery Function When the Page is Loaded and Resized

Category: Code Snippets

When building responsive websites you often want to run a script when the page loads. But when you resize the window the layout breaks. You can use the on method to run your code if the page loads or has been resized. // run on page load and when the window is resized $(window).on(“load resize”,function(e){… Read more »

Continue Reading

How to Visually See What Your jQuery Selection is Selecting

Category: Code Snippets / Tutorials

I was recently working on form validation and wanted to mark a.form-group as successful if it contained a particular icon inside the label. The icon was set using PHP depending if the data existed in the database. I was writing .prev() and .parent() to try and select the wrapping .form-group but it wasn’t working and… Read more »

Continue Reading

How to Get a List of WordPress PDF, Image, Post, or Page URLS

Category: Code Snippets

Below are two PHP scripts you can use to help get a list of URLs of content in your WordPress site. I use these when I am migrating posts or media library files to another sites without using a plugin. Follow the steps below to use these scripts Open a text editor and copy and… Read more »

Continue Reading

How to Prevent One Word Lines (widow orphan) In Website Paragraphs

Category: Code Snippets

I am often adding padding to the left and right of paragraphs to force copy down to prevent one word on a line. Or even worse, I add <br> to a word on the line above to prevent the word by itself. But this causes issues with responsive design because the <br> changes position breaking… Read more »

Continue Reading

How to Trigger HubSpot Popup Form on Button Click or Page Load

Category: Code Snippets

HubSpot provides the ability to display a pop up form with various triggers (exit intent, after 7 seconds, etc.) But what if you want to show it immediately or when a button is clicked? Below is some javascript to help achieve this functionality. How to use this script Create pop up form Set targeting to… Read more »

Continue Reading

How to Redirect Known Pages and Wildcard for Everything Else with htaccess

Category: Code Snippets

I recently worked on a project which needed me to shut down a WordPress blog and migrate it’s content. I had about 20 posts and pages that were going to migrate but everything else was going to be deleted. Since htaccess runs their commands from the top to the bottom, place your known redirects above… Read more »

Continue Reading

Open All Links to PDF files in a New Window

Category: Code Snippets

This finds all of the links pointing to PDF files and opens them in a new window. If you are using Chrome, you will need to enable popups for this to work. $(“a[href$=’.pdf’]”).each(function () { window.open($(this).attr(‘href’),”_blank”); });  

Continue Reading

Check Page Level Depth If Condition in WordPress

Category: Code Snippets

The code snippet below is handy when you are trying to check if the current page is a parent or a child in a WordPress theme. You can then use the conditional to output different code depending on the page depth it is <?php // gets page depth global $wp_query; $object = $wp_query->get_queried_object(); $parent_id =… Read more »

Continue Reading

HTML5 Responsive Autoplay Video Code Snippet

Category: Code Snippets

In order to make your HTML5 video responsive you will need to add the following CSS style properties: width: 100%, and max-height: 100%. Your browser does not support the video tag.

Continue Reading