Skip to content

Instantly share code, notes, and snippets.

@accrane
accrane / functions.php
Created January 3, 2016 13:28
Add Options page to your ACF Dashboard
/* Adds an Options page to your Dashboard */
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
}
@accrane
accrane / gist:813243866dd9f116d47d
Created February 15, 2016 21:48
Find and Replace phpMyAdmin
UPDATE `table_name`
SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')
@accrane
accrane / change-user-role-mysql.txt
Created March 15, 2016 19:44
Change WordPress User Role to Admin mySql
-- Look at the field called "id" in the result set
--
select * from wp_users
where user_login = 'WORDPRESS_USERNAME_GOES_HERE';
-- Substitute the above "id" value in the "user_id" field below.
-- This is an integer value so do not use quotes around it
-- For example if the above "id" is the value 10 then the resulting line would be: where user_id = 10
--
update wp_usermeta
@accrane
accrane / force-upgrade.php
Created March 15, 2016 19:49
Force Upgrade WordPress
<?php
/*
WordPress Force Upgrade Script
Copyright (C) 2006 Mark Jaquith
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
<script>
$(document).ready(function() {
$('.js-title').each(function(index, element) {
var heading = $(element);
var word_array, last_word, first_part;
word_array = heading.html().split(/\s+/); // split on spaces
last_word = word_array.pop(); // pop the last word
first_part = word_array.join(' '); // rejoin the first words together
.last-word {
color: #00f;
}
<h1 class="js-title">My Cool Title</h1>
<?php
// Get RSS Feed(s)
include_once( ABSPATH . WPINC . '/feed.php' );
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( 'http://journeysfromayrden.tumblr.com/rss' );
if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
@accrane
accrane / infinite-previous-next-same-term-looping.php
Last active May 12, 2016 17:18 — forked from banago/infinite-previous-next-looping.php
Infinite next and previous post looping but in same term in WordPress
<?php
/**
* Infinite next and previous post looping in WordPress
*
* This will stay in same Custom Taxonomy Term. Also NEXT and PREVIOUS
* are switched to give the impression of "Going Forard and Back"
*/
if( get_adjacent_post(true, '', false, 'CUSTOM_TAX') ) {
next_post_link( '%link', 'PREVIOUS', TRUE, ' ', 'CUSTOM_TAX' );
@accrane
accrane / yoast-choose-primary-taxonomy-term.php
Last active September 29, 2022 08:20
Using Yoast, "Make Primary Category" for Custom Taxonomies
<?php
// Fill in your custom taxonomy here
$yourTaxonomy = 'CUSTOM_TAXONOMY';
// SHOW YOAST PRIMARY CATEGORY, OR FIRST CATEGORY
$category = get_the_terms( $postId, $yourTaxonomy );
$useCatLink = true;
// If post has a category assigned.
if ($category){
$category_display = '';