Skip to content

Instantly share code, notes, and snippets.

View philiprabbett's full-sized avatar

Philip Rabbett philiprabbett

View GitHub Profile
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty
@pierre-dargham
pierre-dargham / acf-add-group-field-position-before-title.php
Created October 17, 2016 17:11
ACF Before Title : Adds a choice "High (before title) to ACF field groups position drop-down"
<?php
/*
Plugin Name: ACF Before Title
Description: Adds a choice "High (before title) to ACF field groups position drop-down"
Author: Pierre Dargham
Author URI: https://github.com/pierre-dargham/
Version: 1.0
*/
@itzikbenh
itzikbenh / home.php
Last active April 5, 2020 09:30
Very simple infinite scroll in WordPress.
//Just a random file for loading your posts to see that the infinite scroll works.
<?php get_header(); ?>
<div class="col-md-6 col-md-offset-3">
<div class="post-container">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="page-header post">
<h1><?php the_title(); ?></h1>
<p><?php the_excerpt(); ?></p>
</div>
@johnregan3
johnregan3 / wp-amp-tutorial-featured-images.php
Created July 21, 2016 18:13
Add Featured Images to a WordPress AMP Template
@AbhishekGhosh
AbhishekGhosh / gistlist.php
Created May 28, 2016 03:26
Github Git List with PHP
<?php
if (isset($_POST['button']))
{
$code = $_POST['code'];
# Creating the array
$data = array(
'description' => 'description for your gist',
'public' => 1,
'files' => array(
@max-kk
max-kk / filter_user_avatar.php
Created March 13, 2016 11:34
Wordpress: How to filter & replace user avatar based on meta filed (where saved avatar attachment_id).
<?php
function custom_modify_get_avatar($args, $id_or_email) {
$avatar_att_id = get_user_meta( get_current_user_id(), '_avatar_att_id', true );
if($avatar_att_id) {
$avatar_att_url = wp_get_attachment_image_src($avatar_att_id, array($args['width'], $args['height']));
if ( !empty($avatar_att_url) ) {
$args['url'] = $avatar_att_url[0];
}
}
return $args;
@schalkburger
schalkburger / wordpress-remove-cssjs-ver.php
Last active August 4, 2017 19:54
Wodrdpress remove CSS and JS version number that is appended
function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );
@ideag
ideag / old-plugin.php
Created September 1, 2015 12:36
WordPress rename plugin main PHP file
<?php
/*
Plugin Name: Old Plugin main file
Description: Rename Old plugin main file (i.e. index.php) to `plugin-slug.php`
Version: 0.1.0
Author: Arūnas Liuiza
Author URI: http://arunas.co
License: GPL2
*/
@thefuxia
thefuxia / whereami.php
Created July 4, 2015 08:21
Where am I?
<?php
/* Plugin Name: Where am I?
* Description: Adds the current server name and WordPress path to the admin footer.
* Version: 2015.07.04
* Author: toscho
* Author URI: http://wpkrauts.com/
* License: MIT
* License URI: http://opensource.org/licenses/MIT
*/
add_filter( 'admin_footer_text', function( $text ) {
@schalkburger
schalkburger / remove-wordpress-emoji.php
Created May 15, 2015 09:14
Remove Wordpress emoji
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );