Skip to content

Instantly share code, notes, and snippets.

@marcbacon
marcbacon / email-template-function.php
Last active November 15, 2023 22:15
Add Email Template to WordPress Theme
<?php
/**
* Use an HTML Email Template for All Sends
* Add this file to functions.php
*/
function your_email_template($args) {
if (!is_array($args)) {
return $args;
@marcbacon
marcbacon / Check Even.php
Last active December 20, 2017 17:07
[PHP Check Even Numbers] #php
$number = 20;
if ($number % 2 == 0) {
print "It's even";
}
@marcbacon
marcbacon / Atom
Last active March 17, 2017 19:20
A collection of tips and packages for Atom.
# Editor Settings
(Settings > Editor)
Enable Soft Wrap (so that you do not have to scroll left)
Set tab length to 4
# Packages
* = Most useful
@marcbacon
marcbacon / Email Example.html
Last active November 11, 2016 20:22
Example email styles.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;UTF-8" />
<style>
a {
color: #00b3be;
}
</style>
</head>
@marcbacon
marcbacon / ACF Repeater.php
Last active September 26, 2017 20:11
[ACF Repeater] ACF repeater syntax simplified. #wordpress #acf
<?php if( have_rows('repeater_field_name') ): // check if the repeater field has rows of data ?>
<?php while ( have_rows('repeater_field_name') ) : the_row(); // loop through the rows of data ?>
<?php the_sub_field('sub_field_name'); // display a sub field value ?>
<?php endwhile; ?>
<?php endif; ?>
@marcbacon
marcbacon / Featured Image Instructions.php
Created August 17, 2016 22:27
Add instructions to the featured image metabox in the post editor.
@marcbacon
marcbacon / Move Yoast Metabox.php
Created August 1, 2016 21:33
Move Yoast SEO Metabox to the bottom of the posts screen (change its priority)
// Move Yoast SEO Metabox to the bottom of the posts screen
add_filter( 'wpseo_metabox_prio', function() { return 'low';});
@marcbacon
marcbacon / anchor-hash-test.js
Created April 25, 2016 18:25
Test for an anchored hash and save the hash to a variable.
if(window.location.hash) {
var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
alert (hash);
// hash found
} else {
// No hash found
}
@marcbacon
marcbacon / WordPress-SQL.mysql
Last active April 13, 2016 14:05
Useful WordPress SQL queries.
# Delete all unapproved comments
DELETE FROM wp_comments WHERE comment_approved = 0
# Test to see what pages are using a certain page template
SELECT * FROM `wp_postmeta` WHERE `meta_value` like 'page-library.php'
# Get a post by ID
SELECT * FROM `wp_posts` WHERE `ID` = 1128
@marcbacon
marcbacon / Page Template Query.mysql
Created April 11, 2016 19:53
Test to see what pages are using a page template. MySQL
SELECT * FROM `wp_postmeta` WHERE `meta_value` like 'page-library.php'