Skip to content

Instantly share code, notes, and snippets.

View DarioBF's full-sized avatar
⌨️

DarioBF

⌨️
View GitHub Profile
@DarioBF
DarioBF / Preferences.sublime-settings
Last active February 25, 2016 20:49
Sublime Text 3 preferences
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"font_options":
[
"gray_antialias",
"subpixel_antialias"
],
"font_size": 13,
@DarioBF
DarioBF / functions.php
Created January 26, 2016 12:07
Allow SVG files uploads in WordPress
/**
* Allow uploads for SVG files.
*/
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
/**
@DarioBF
DarioBF / functions.php
Created February 15, 2016 15:16
Change number of products per page on WooCommerce
// Display 24 products per page. Goes in functions.php
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 );
UPDATE wp_options SET option_value = replace(option_value, 'http://site-to-change.com', 'http://127.0.0.1/site-changed') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, 'http://site-to-change.com', 'http://127.0.0.1/site-changed');
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://site-to-change.com', 'http://127.0.0.1/site-changed');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://site-to-change.com', 'http://127.0.0.1/site-changed');
add_action( 'init', 'bf_register_custom_post_type' );
/**
* Registro un custom post type 'libro'.
*
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function bf_register_custom_post_type() {
/* Añado las etiquetas que aparecerán en el escritorio de WordPress */
$labels = array(
'name' => _x( 'Libros', 'post type general name', 'text-domain' ),
@DarioBF
DarioBF / CPTs 2
Last active November 28, 2020 05:57
// Lo enganchamos en la acción init y llamamos a la función create_book_taxonomies() cuando arranque
add_action( 'init', 'create_book_taxonomies', 0 );
// Creamos dos taxonomías, género y autor para el custom post type "libro"
function create_book_taxonomies() {
/* Configuramos las etiquetas que mostraremos en el escritorio de WordPress */
$labels = array(
'name' => _x( 'Géneros', 'taxonomy general name' ),
'singular_name' => _x( 'Género', 'taxonomy singular name' ),
'search_items' => __( 'Buscar por Género' ),
// Añado otra taxonomía, esta vez no es jerárquica, como las etiquetas.
$labels = array(
'name' => _x( 'Escritores', 'taxonomy general name' ),
'singular_name' => _x( 'Escritor', 'taxonomy singular name' ),
'search_items' => __( 'Buscar Escritores' ),
'popular_items' => __( 'Escritores populares' ),
'all_items' => __( 'Todos los escritores' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Editar Escritor' ),
/** Función que elimina todo rastro de fechas en los artículos */
function bf_remove_dates() {
add_filter('the_time', '__return_false');
add_filter('get_the_time', '__return_false');
add_filter('the_modified_time', '__return_false');
add_filter('get_the_modified_time', '__return_false');
add_filter('the_date', '__return_false');
add_filter('get_the_date', '__return_false');
add_filter('the_modified_date', '__return_false');
add_filter('get_the_modified_date', '__return_false');
add_action('wp', 'bf_remove_dates');
/** Función que elimina todo rastro de fechas en los artículos */
function bf_remove_dates() {
if( is_singular('libros') ){
add_filter('the_time', '__return_false');
add_filter('get_the_time', '__return_false');
add_filter('the_modified_time', '__return_false');
add_filter('get_the_modified_time', '__return_false');
add_filter('the_date', '__return_false');
add_filter('get_the_date', '__return_false');
add_filter('the_modified_date', '__return_false');