Skip to content

Instantly share code, notes, and snippets.

View heytricia's full-sized avatar

Tricia Francis heytricia

  • WP Goodness
  • Lafayette, CO
  • 06:22 (UTC -06:00)
View GitHub Profile
@NickDeckerDevs
NickDeckerDevs / readtime.hubspot.html
Last active February 15, 2018 05:35
Hubspot hubl read time for blogs / content
{# RENDER READ TIME #}
{% macro render_read_time(body) %}
{% set str = body|lower %}
{% set img_count = str|split('<img')|length %}
{% set img_minutes = ((img_count * 12) / 60)|round(0, 'common') %}
{% set read_time = (str|striptags|wordcount / 275)|round(0, 'common') + img_minutes %}
{{ read_time|string|trim ~ ' ' ~ render_read_time_suffix()|trim }}
{% endmacro %}
{# And here's the meta info for the <head> of the custom template... #}
@kevinwhoffman
kevinwhoffman / responsive-images-notes.md
Last active May 18, 2020 13:31
WordPress 4.4 Responsive Images Notes

Notes and Resources for Responsive Images in WordPress 4.4

Following the addition of responsive images support in WordPress 4.4, there has been a lot of confusion over what WordPress does "automatically" and what is left up to the developer. I've gathered the following notes from chatting with members of the core team and also my own investigation of the 4.4 source. Here's what I've discovered:

  • Following the 4.4 update, WordPress automatically serves the following images responsively:

    • Content images added via the main content editor will now be served with srcset markup. This is accomplished by filtering the_content() prior to display, which means it applies to existing posts and new posts going forward.
    • Featured images called by the_post_thumbnail() also get srcset markup without any additional steps required.
  • Images that are referenced from custom fields will not be served responsively unless the theme calls the image via wp_get_attachment_image() OR constructst the responsive m

@mattclements
mattclements / function.php
Last active July 2, 2024 15:32
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@timkeller
timkeller / application.js
Created February 9, 2012 11:23
JS to make .subnav sticky
!function ($) {
$(function(){
// fix sub nav on scroll
var $win = $(window)
, $nav = $('.subnav')
, navTop = $('.subnav').length && $('.subnav').offset().top - 40
, isFixed = 0