Skip to content

Instantly share code, notes, and snippets.

@tesseslol
tesseslol / FrontedTopic.md
Last active February 4, 2023 20:47
A curated list of topics
@rveitch
rveitch / sync_acf_post_title.php
Last active February 1, 2025 00:34
Update WordPress post title from an ACF field value on save. (Advanced Custom Fields)
<?php
/**
* Update Post Title from an ACF field value on post save.
*
* Triggers on save, edit or update of published posts.
* Works in "Quick Edit", but not bulk edit.
*/
function sync_acf_post_title($post_id, $post, $update) {
$acf_title = get_field('my_acf_field_name', $post_id); // NOTE: enter the name of the ACF field here
@Hay1tsme
Hay1tsme / ChallongeDiscord.js
Last active June 27, 2023 08:13
Simple node.js app that uses Discords webhook feature to push match updates about a challonge.com tournament. Requires request, fs and timers are global
'use strict';
//Program by Kevin 'Hay1tsme' Trocolli
//Uses Discord webhooks to push updates about a Challonge tournament to a discord server via text message
const request = require('request');
const fs = require('fs');
const timer = require('timers')
const hook = "<Discord Webhook Here>"
const chal = "https://api.challonge.com/v1/tournaments/<subdomain>-<tournimentURL>/matches.json?api_key=<apiKey>&state=complete"
@PauliusKrutkis
PauliusKrutkis / set-image.php
Created July 6, 2017 13:35
Wordpress set post thumbnail with media_sideload_image function
<?php
require_once(ABSPATH . 'wp-admin/includes/media.php');
require_once(ABSPATH . 'wp-admin/includes/file.php');
require_once(ABSPATH . 'wp-admin/includes/image.php');
$url = 'http://wordpress.org/about/images/logos/wordpress-logo-stacked-rgb.png';
$title = "Anything you want";
$postId = 1;
@devinsays
devinsays / estimate-read-time.php
Last active February 11, 2023 20:57
WordPress Estimated Read Time
<?php
/**
* Estimates the reading time for a given piece of $content.
*
* @param string $content Content to calculate read time for.
* @param int $wpm Estimated words per minute of reader.
*
* @returns int $time Esimated reading time.
*/
function prefix_estimated_reading_time( $content = '', $wpm = 300 ) {
@Niq1982
Niq1982 / wpcli-ai1wm.md
Last active February 25, 2025 15:29
Site migration using All in One WP Migration and WP CLI

Do a backup

Install the plugin

wp plugin install all-in-one-wp-migration --activate

You must reload the page once before continuing

Do the backup

@kierzniak
kierzniak / functions.php
Created January 17, 2018 21:55
Search across all network blogs in elasticpress
<?php
/**
* Search across all network blogs with elasticpress
*
* @param $scope string Search scope
*
* @return string
*/
function motivast_ep_search_scope( $scope ) {
@anwas
anwas / wp-config.php
Last active November 10, 2021 11:35
[WordPress wp-config customization]
<?php
/* WordPress debug mode for developers. */
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@jsn789
jsn789 / add-gtm-wp.php
Last active September 4, 2024 13:38
Add Google Tag Manager through functions.php in WordPress
/* Add Google Tag Manager javascript code as close to
the opening <head> tag as possible
=====================================================*/
function add_gtm_head(){
?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=