Skip to content

Instantly share code, notes, and snippets.

View not-only-code's full-sized avatar
👾
Looking for work!

Carlos Sanz García not-only-code

👾
Looking for work!
View GitHub Profile
@not-only-code
not-only-code / endpoints.php
Created August 31, 2012 10:57 — forked from joncave/endpoints.php
WP_Rewrite endpoints demo
<?php
/*
Plugin Name: WP_Rewrite endpoints demo
Description: A plugin giving example usage of the WP_Rewrite endpoint API
Plugin URI: http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/
Author: Jon Cave
Author URI: http://joncave.co.uk/
*/
function makeplugins_endpoints_add_endpoint() {
@not-only-code
not-only-code / .htaccess
Last active October 5, 2015 22:58
Web fonts .htaccess snippet
# BEGIN REQUIRED FOR WEBFONTS
AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
@not-only-code
not-only-code / functions.php
Last active October 5, 2015 22:47
Wordpress: get hierarchical post ancestor
/**
* get hierarchical post ancestor (level 0)
*
* @param int|object $post
* @return object post ancestor
*
* @usage get_post_ancestor(131) | get_post_ancestor($post)
*
**/
function get_post_ancestor( $post = false ) {
@not-only-code
not-only-code / gist:2889579
Created June 7, 2012 15:47
adds meta query on Wordpress search
/**
* adds meta values on search query
*
* @param object $query
*
**/
function custom_search_query( $query ) {
if ( !is_admin() && $query->is_search ) {
$query->set('meta_query', array(
array(