Skip to content

Instantly share code, notes, and snippets.

View vsalda's full-sized avatar

Victor Saldarriaga vsalda

  • Cognizant
  • La Rioja, Spain
View GitHub Profile
@vsalda
vsalda / plugin-name.php
Last active August 29, 2015 14:14
Código para crear un tipo de entrada personalizado en WordPress
add_action( 'init', 'custom_post_type', 0 );
function custom_post_type() {
$labels = array(
'name' => _x( 'Post Types', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Post Type', 'Post Type Singular Name', 'text_domain' ),
// 'menu_name' => __( 'Post Type', 'text_domain' ), // default to 'name'
'add_new' => __( 'Add New', 'text_domain' ),
'add_new_item' => __( 'Add New Item', 'text_domain' ),
@vsalda
vsalda / style.css
Last active August 29, 2015 14:14
Cabecera del archivo style.css al crear un tema hijo.
/*
Theme Name: Twenty Fourteen Child
Theme URI: http://example.com/twenty-fourteen-child/
Description: Twenty Fourteen Child Theme
Author: Victor Saldarriaga
Author URI: http://bonsaipress.es
Template: twentyfourteen
Version: 1.0.0
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fourteen-child
@vsalda
vsalda / functions.php
Last active August 29, 2015 14:10
Remove Jetpack OG tags for compatibility with WordPress SEO plugin
/**
* Remove Jetpack OG tags
*/
add_filter( 'jetpack_enable_open_graph', '__return_false' );
<?php
/**
* Configurar el textdomain de nuestro tema hijo.
*
* Utilizamos el hook 'after_setup_theme' y enganchamos nuestra función.
* Las traducciones deben ir dentro del directorio /languages/ en nuestro tema hijo.
*/
function twentyfourteen_child_theme_setup() {
load_child_theme_textdomain( 'twentyfourteen-child-theme', get_stylesheet_directory() . '/languages' );
}
@vsalda
vsalda / functions.php
Last active August 29, 2015 14:10
Añadir a favicon en formato png a un tema hijo.
<?php // <-- ignorar el inicio de las etiqueta PHP, el codigo debe ir en el archivo functions.php del tema hijo
// Enganchamos la función twentyfourteen_child_favicon_link al hook wp_head
add_action( 'wp_head', 'twentyfourteen_child_favicon_link' );
/**
* Incluir un favicon en formato png
*/
function twentyfourteen_child_favicon_link() {
echo '<link rel="shortcut icon" type="image/x-icon" href="'. get_stylesheet_directory_uri() .'/images/favicon.png" />';
}
@vsalda
vsalda / functions.php
Last active August 29, 2015 14:10
Incluir hojas de estilos del tema padre y luego del tema hijo. Tutorial para crear un tema hijo para Twentyfourteen
<?php
add_action( 'wp_enqueue_scripts', 'twentyfourteen_parent_theme_style');
function twentyfourteen_parent_theme_style() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
add_action( 'wp_enqueue_scripts', 'twentyfourteen_child_styles', 20 );
@vsalda
vsalda / disable_sidebars.php
Last active December 26, 2015 09:59
Hybrid Core: Fillter sidebar_widgets hook when layout is one column and when viewing from customizer
<?php
/* Disable primary sidebar_widgets when layout is one column and when viewing from customizer. */
add_filter( 'sidebars_widgets', 'disable_sidebars' );
function disable_sidebars($sidebars_widgets) {
global $wp_customize;
$customize = ( is_object( $wp_customize ) && $wp_customize->is_preview() ) ? true : false;
/* Add any 1c column template inside the ( || ) conditinal */