Skip to content

Instantly share code, notes, and snippets.

View fernandiez's full-sized avatar

Fernan fernandiez

View GitHub Profile
@fernandiez
fernandiez / index.php
Last active September 6, 2016 17:06
WordPress WP_Query with just sticky posts - page.php or index.php template
<?php
/**
* WordPress WP_Query with just sticky posts - page.php or index.php template
**/
get_header(); // loads header.php template ?>
<?php $custom_query = new WP_Query('posts_per_page=1'); ?>
<div id="wrap-sample" class="blog-sample clearfix">
@fernandiez
fernandiez / function.php
Created October 4, 2016 23:32
Adding WordPress Taxonomy title and description (category, tag, taxonomy)
//* Adding WordPress Taxonomy title and description (category, tag, taxonomy)
/**
* Add Category Heading to Each Page in Pagination in Genesis
* @link https://gist.github.com/neilgee/6c0414cfef06e41a6606
* Prints a category's title and description in Genesis
* @link https://gist.github.com/EngageWP/df43e156e76fa5cdd6c0
*/
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
@fernandiez
fernandiez / functions.php
Created October 19, 2016 09:31
Custom permalink structure only for WordPress default posts
// Custom permalink structure only for default WordPress posts
// https://wordimpress.com/how-to-add-a-custom-permalink-structure-for-only-the-wordpress-default-post-type/
add_action( 'init', 'my_new_default_post_type', 1 );
function my_new_default_post_type() {
register_post_type( 'post', array(
'labels' => array(
'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
),
@fernandiez
fernandiez / functions.php
Created November 21, 2016 10:35
Remove post titles from home page in Genesis Framework
//* Remove post titles from home page in Genesis Framework
//* http://my.studiopress.com/snippets/entry-header/
//* http://www.billerickson.net/genesis-h1-front-page/
//* http://wpsites.net/web-design/remove-titles-specific-conditions/
add_action( 'get_header', 'remove_titles_home_page' );
function remove_titles_home_page() {
if ( is_front_page() ) {
//* Remove the entry title (requires HTML5 theme support)
@fernandiez
fernandiez / functions.php
Created November 25, 2016 10:32
Disable Emojis in WordPress
/**
* Disable the emoji's
* https://woorkup.com/disable-emojis-in-wordpress/
*/
function disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
@fernandiez
fernandiez / .htaccess
Created November 25, 2016 13:04
WP Super Cache + Leverage Browser Caching WordPress .htaccess
# WP Super Cache + Leverage Browser Caching WordPress .htaccess
# http://notlaura.com/wp-super-cache-and-browser-caching/
# BEGIN WPSuperCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_URI} !^.*[^/]$
@fernandiez
fernandiez / style-01.css
Last active November 30, 2016 17:35
Using custom fonts CSS @font-face in a WordPress theme
/* Fonts
--------------------------------------------- */
@font-face {font-family: "Century Gothic";
src: url("fonts/century-gothic.eot");
src: url("fonts/century-gothic.eot?#iefix") format("embedded-opentype"),
url("fonts/century-gothic.woff2") format("woff2"),
url("fonts/century-gothic.woff") format("woff"),
url("fonts/century-gothic.ttf") format("truetype"),
url("fonts/century-gothic.svg#Century Gothic") format("svg");
@fernandiez
fernandiez / SQL-query.txt
Last active February 2, 2017 15:13
SQL query
INSERT INTO `DATABASENAME`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'USER', MD5('PASSWORD'), 'YOUR NAME', 'EMAIL@DOMAIN.COM', 'http://www.domain.com/', '2011-06-07 00:00:00', '', '0', 'YOUR NAME');
INSERT INTO `DATABASENAME`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `DATABASENAME`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');
@fernandiez
fernandiez / page_fullwidth.php
Created February 3, 2017 16:16
Genesis Framework Full Width Page Template
<?php
/**
* Genesis Framework Full Width Page Template
*
* @author Fernan Díez
* @license GPL-2.0+
* @link http://www.fernan.com.es/
*/
// Template Name: Full Width
@fernandiez
fernandiez / functions.php
Last active February 21, 2017 17:00
Adds shortcode content in Genesis Before Content
// Adds shortcode content in Genesis Before Content
add_action( 'genesis_before_content', 'genesis_slider_header_home' );
function genesis_slider_header_home() {
if ( is_front_page() && is_home() ) {
echo '<br></br>';
} elseif ( is_front_page()){