Skip to content

Instantly share code, notes, and snippets.

View rtpHarry's full-sized avatar
🎯
Focusing on learning something every day

Matthew Harris rtpHarry

🎯
Focusing on learning something every day
View GitHub Profile
@rtpHarry
rtpHarry / functions.php
Last active June 5, 2025 11:57
Force All Results For Specific Archive Pages
<?php
add_action('pre_get_posts', function ($query) {
if (
!is_admin() &&
// for me I commented this out in the end as my ajax grid sort by query was going back to a smaller set of results
// but it is risky, as it could affect other parts of the site like related posts, or sidebar widgets
// test it out on your site, and if it breaks then you will need to dig in and find a way to detect which query
// to filter:
// $query->is_main_query() &&
@rtpHarry
rtpHarry / gist:6e1d73d026fca369569f11798736dc7a
Last active October 14, 2022 22:41 — forked from felixzapata/gist:9144986
How to create a clone role in WordPress
<?php
/**
* Clone the subscriber role to create a tenant role
* Note: this only needs to be run once, so it can be removed after the role is created
*/
function clone_subscriber_to_tenant() {
$new_role = 'tenant';
$new_role_name = 'Tenant';
$source_role = 'subscriber';
@rtpHarry
rtpHarry / rtp-post-grid-parent-title-with-linkphp
Created September 13, 2022 14:20
WordPress Post Grid Layout - Parent Title With Link
<?php
/*
Plugin Name: Post Grid Layout - Parent Title With Link
Plugin URI: https://runthings.dev/
Description: Display the parent page title in the layout editor, with optional link.
Version: 1.0.0
Author: runthings.dev
Author URI: https://runthings.dev/
*/
@rtpHarry
rtpHarry / rtp-post-grid-yoast-primary-category.php
Created September 13, 2022 09:19
WordPress Post Grid - Yoast Primary Category Support
<?php
/*
Plugin Name: Post Grid Yoast Primary Category
Plugin URI: https://runthings.dev/
Description: Bring the primary category to the start of the list
Version: 1.0.0
Author: runthings.dev
Author URI: https://runthings.dev/
*/
@rtpHarry
rtpHarry / soka-elementor-image-carousel-galleryid.php
Last active June 14, 2021 21:40
Inject a randomised prefix into Elementor Image Carousels so that it separates out the lightboxes contained in JetEngine listings
@rtpHarry
rtpHarry / functions.php
Created May 21, 2021 23:56
Convert a start and end timestamp into a nicely formatted and joined up date range
<?php
/**
* Filter for Unlimited Elements to format a date range, from two timestamps
*/
function filter_format_date_range($startTimeStamp, $endTimeStamp){
$displayDate = "";
if($startTimeStamp == $endTimeStamp) {
// same date
$displayDate = date('j M Y', $endTimeStamp);
@rtpHarry
rtpHarry / WordPress Google Analytics
Last active March 16, 2019 21:31 — forked from kenhowardpdx/WordPress Google Analytics
Add Google Analytics to WordPress Theme functions.php
// originally based on https://gist.github.com/kenhowardpdx/8484076
// updated to current gtag.js snippet and moved to head
function rtp_init_analytics() {
$analytics_id = 'YOUR UA CODE HERE';
$analytics = '<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id='. $analytics_id .'"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
@rtpHarry
rtpHarry / animation.js
Last active September 11, 2024 02:25
Three.js - play an AnimationAction in reverse. There are a bunch of threads saying this isn't possible but I found a way so I wanted to post it online in a place that people will hopefully stumble upon it.
// The class itself is based on the animation helper class in
// https://github.com/paulmg/ThreeJS-Webpack-ES6-Boilerplate
// but I have changed almost everything except for the class name and the update function.
import * as THREE from 'three';
export default class Animation {
constructor(scene, animations) {
this.scene = scene;
this.animations = animations;
@rtpHarry
rtpHarry / animation.js
Created October 6, 2018 15:39
Three.js play an AnimationAction in reverse
import * as THREE from 'three';
export default class Animation {
constructor(scene, animations) {
this.scene = scene;
this.animations = animations;
this.mixer = new THREE.AnimationMixer(this.scene);
}
@rtpHarry
rtpHarry / Orchard-Documentation-Notes.md
Created April 16, 2016 12:08
Some notes that I've made so far for contributing to the orchard docs project

Documentation Glossary

  • Admin Dashboard Anything within the admin panel is referred to as the admin dashboard

  • Orchard Just refer to it as Orchard not Orchard CMS or Orchard Project.

  • Guide A page of docs. Not a topic, tutorial, lesson, etc.