Skip to content

Instantly share code, notes, and snippets.

@erkattak
erkattak / NextGEN-Cover-Image.php
Created May 30, 2011 21:40
WordPress - Pull NextGEN Gallery Preview Image using Gallery ID
<?php
$gallery_id = 1; // Use the PODS column, custom post field or however you would get this ID
$results = $wpdb->get_results("SELECT ng.path, np.filename FROM wp_ngg_pictures np, wp_ngg_gallery ng WHERE np.galleryid=ng.gid AND np.galleryid=".$gallery_id." AND np.pid=ng.previewpic",ARRAY_A);
if(!empty($results[0]['path']) && !empty($results[0]['filename'])) :
$imgpath = $results[0]['path'].'/'.$results[0]['filename'];
endif;
@keeguon
keeguon / countries.json
Created April 5, 2012 11:11
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@malarkey
malarkey / Contract Killer 3.md
Last active May 24, 2024 23:38
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@mattboon
mattboon / gist:4202188
Created December 4, 2012 09:34
WordPress - Split content above and below <!--more--> tag
<?php
$morestring = '<!--more-->';
$explode_content = explode( $morestring, $post->post_content );
$content_before = apply_filters( 'the_content', $explode_content[0] );
$content_after = apply_filters( 'the_content', $explode_content[1] );
?>
@lucasstark
lucasstark / gist:6594983
Created September 17, 2013 14:21
Example to add meta data to woocommerce cart items
<?php
/*
* Plugin Name: Example Modify Price
*/
class Example_Modify_Price {
private static $instance;
public static function register() {
if (self::$instance == null) {
@TimBHowe
TimBHowe / functions.php
Last active May 24, 2022 16:21
Add "Company" field to WordPress user account and add sortable company column to the user backend.
//add&remove field from user profiles - sorce:http://davidwalsh.name/add-profile-fields
function modify_contact_methods($profile_fields) {
// Add new fields
$profile_fields['company'] = 'Company';
// Remove old fields
//unset($profile_fields['aim']);
return $profile_fields;
@TimBHowe
TimBHowe / functions.php
Created March 7, 2014 22:15
Change the WordPress gallery html output
<?php
//Modify the output of the gallery short code
add_filter('post_gallery', 'scaffolding_post_gallery', 10, 2);
function scaffolding_post_gallery($attr) {
$post = get_post();
static $instance = 0;
$instance++;
if ( ! empty( $attr['ids'] ) ) {
@larrybotha
larrybotha / A.markdown
Last active March 3, 2021 10:41
Custom social sharing icons
@portfola
portfola / author.php
Last active May 6, 2023 18:15
Custom User Taxonomies in WordPress
<?php
/**
* The template for displaying Profile pages.
*
* Used for Artist and Cultural Org "mini" pages.
*
* @package ArtsWestchester
* @since ArtsWestchester 1.0
*/
@amdrew
amdrew / gist:1119f025ad896c05e2f5
Last active April 6, 2017 15:07
AffiliateWP - Custom logout redirect for Affiliates
<?php
/**
* AffiliateWP - Custom logout redirect for Affiliates
* By default, a user is sent to the wp-login.php?loggedout=true page
* Affiliates are logged out to the affiliate dashboard login screen
* Normal WP users are logged out and redirected to the site URL
*/
function affwp_custom_logout_redirect( $logout_url, $redirect ) {