Skip to content

Instantly share code, notes, and snippets.

@aaronsummers
aaronsummers / reset-acf-metabox.php
Last active March 19, 2021 14:09 — forked from electricbrick/reset-acf-metabox.php
Reset ACF Metabox Positions
<?php
$user_id = 1;
$custom_post_type = 'my_post_type';
function prefix_reset_metabox_positions(){
delete_user_meta( $user_id, 'meta-box-order_post' ); // Posts
delete_user_meta( $user_id, 'meta-box-order_page' ); // Pages
delete_user_meta( $user_id, 'meta-box-order_' . $custom_post_type ); // Custom post types
}
add_action( 'admin_init', 'prefix_reset_metabox_positions' );
@aaronsummers
aaronsummers / wp-post_status-change.SQL
Created March 9, 2021 21:39 — forked from micjamking/wp-post_status-change.SQL
Bulk update ALL WordPress post statuses in SQL
# Change post_type value if targeting 'page' or a custom post type
# Change ALL posts status from 'publish' to 'draft'
UPDATE wp_posts SET post_status = 'publish' WHERE (post_type = 'post' and post_status = 'draft')
@aaronsummers
aaronsummers / mailhog-mamp.md
Created November 5, 2020 14:50 — forked from jaredatch/mailhog-mamp.md
Install MailHog with MAMP Pro

Install MailHog with MAMP Pro, using HomeBrew.

MailHog

First let's make sure HB is updated. Open up terminal for the following steps.

$ brew update
@aaronsummers
aaronsummers / WordPress Theme Customizer Sample.php
Last active January 31, 2020 09:33 — forked from Abban/WordPress Theme Customizer Sample.php
WordPress Theme Customizer Sample
<?php
function themename_customize_register($wp_customize)
{
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'priority' => 120
));
(function() {
var touchingCarousel = false,
touchStartCoords;
document.body.addEventListener('touchstart', function(e) {
if (e.target.closest('.flickity-slider')) {
touchingCarousel = true;
} else {
touchingCarousel = false;
return;
@aaronsummers
aaronsummers / ACF Gutenberg get block fields
Last active January 13, 2020 10:18 — forked from jenssogaard/ACF Gutenberg get block fields
Helper class for ACF and Gutenberg. Get blocks fields by passing block_id and post_id.
<?php
class BlockHelper
{
public function getBlockFromPage(string $block_name, int $post_id)
{
$post = get_post($post_id);
if (!$post) return false;
$blocks = parse_blocks($post->post_content);
@aaronsummers
aaronsummers / .htaccess
Created December 27, 2019 12:12 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@aaronsummers
aaronsummers / infinite-previous-next-looping.php
Created October 5, 2018 19:55 — forked from banago/infinite-previous-next-looping.php
Infinite next and previous post looping in WordPress
<?php
/**
* Infinite next and previous post looping in WordPress
*/
if( get_adjacent_post(false, '', true) ) {
previous_post_link('%link', '&larr; Previous Post');
} else {
$first = new WP_Query('posts_per_page=1&order=DESC'); $first->the_post();
echo '<a href="' . get_permalink() . '">&larr; Previous Post</a>';
wp_reset_query();
@aaronsummers
aaronsummers / eu_cookie_banner.js
Created May 2, 2018 14:20 — forked from bavington/eu_cookie_banner.js
Simple EU Cookie Law Banner JavaScript