Skip to content

Instantly share code, notes, and snippets.

if ( $query->is_home() && $query->is_main_query() ) {
$posts_per_page = 8;
$page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 0;
$query->set( 'offset', 5 + $posts_per_page * $page );
$query->set( 'posts_per_page', $posts_per_page );
}
<?php
/**
* Primary Nav using Dropdown Walker
*
* @param array $args
* @return array
*/
function be_primary_nav_dropdown( $args ) {
if( 'primary' !== $args['theme_location'] || !class_exists( 'Walker_Nav_Menu_Dropdown' ) )
@GaryJones
GaryJones / gist:cfe0f917f144da8c908e
Last active August 29, 2015 14:06
Gamajo Accessible Menu plugin
/**
* Gamajo Accessible Menu.
*
* Improves menu accessibility in two ways:
* * Adds a delay to submenus disappearing when moving the mouse away.
* * Makes submenus appear when tabbing through menu items with the keyboard.
*
* Kudos to Rian Rietveld for the code on which this plugin is based.
*
* After enqueueing this file (or concatenating it with your theme JS file),
@norcross
norcross / yoast-ga-menu-move.php
Last active August 29, 2015 14:06
move Yoast Google Analytics top-level nav to a sub menu
/**
* move the main settings page for Yoast Google Analytics
* from it's own parent menu into a submenu page in either
* the Yoast SEO menu or in the general settings
*
* @return null
*/
function rkv_yoast_ga_menu() {
// check for the Yoast GA class in the event the plugin
@richardbuff
richardbuff / gist:ca05441197668ae28b68
Last active August 29, 2015 14:22
Sublime Snippets For PHP echo of HTML opening and closing tags
// Save as: php-echo-open-html.sublime-snippet
<snippet>
<content><![CDATA[
echo '<${1:div} ${2:class}="${3:value}">';
]]></content>
<description>PHP echo statement with opening html tag with class</description>
<tabTrigger>phpechohtmlopen</tabTrigger>
<scope>source.php.embedded.block.html</scope>
</snippet>
@chipbennett
chipbennett / skype_toolbar_meta.php
Created October 19, 2011 17:41
Stop Skype from hijacking phone numbers
<?php
/**
* Stop Skype from hijacking phone numbers
*
* Adds a META tag to the HTML document head, that
* prevents Skype from hijacking/over-writing phone
* numbers displayed in the Theme.
*
* @link http://www.wpbeginner.com/wp-tutorials/how-to-fix-skype-overwriting-phone-numbers-in-wordpress-themes/ H/T WPBeginner
*/
@johnpbloch
johnpbloch / short-circuit.php
Created November 21, 2011 20:10
Short Circuit a post save in WordPress and give the user a notice saying why.
<?php
namespace JPB;
function wp_insert_post_data( $data, $postarr ){
if($data['foo'] !== 'bar' || $data['baz'] !== 'bat'){
wp_redirect( add_query_arg( array( 'post' => $data['ID'], 'action' => 'edit', 'message' => 11 ), admin_url( 'post.php' ) ) );
exit;
}
return $data;
@GaryJones
GaryJones / functions.php
Created January 31, 2012 00:47
Include Facebook Open Social namespaces.
<?php
remove_action( 'genesis_doctype', 'genesis_do_doctype' );
add_action( 'genesis_doctype', 'child_do_doctype' );
/**
* Include Facebook Open Social namespaces.
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/modify-doctype/
*/
@billerickson
billerickson / widget nav.php
Created February 11, 2012 01:13 — forked from chadmohr/widget nav
Genesis widget area next to nav
<?php
add_filter( 'genesis_nav_items', 'sws_social_icons', 10, 2 );
add_filter( 'wp_nav_menu_items', 'sws_social_icons', 10, 2 );
function sws_social_icons($menu, $args) {
$args = (array)$args;
if ( 'primary' !== $args['theme_location'] )
return $menu;
ob_start();
@GaryJones
GaryJones / gist:1802903
Created February 11, 2012 17:35
SVN command to make a WordPress plugin tag
# Here we're copying the trunk of one of my plugins, to a tag of 1.3.0, with a simple message.
svn copy https://plugins.svn.wordpress.org/genesis-admin-bar-plus/trunk https://plugins.svn.wordpress.org/genesis-admin-bar-plus/tags/1.3.0 -m "Release 1.3.0"