Skip to content

Instantly share code, notes, and snippets.

View pablocattaneo's full-sized avatar

Pablo Cattaneo pablocattaneo

View GitHub Profile
@pablocattaneo
pablocattaneo / display-custom-field.php
Last active September 16, 2017 00:09
Muestra el custom field que se indica en la variable Key
// $key="mykey" nombre de custom field tal como se escribe en el post
<?php $key="mykey"; echo get_post_meta($post->ID, $key, true); ?>
@pablocattaneo
pablocattaneo / replace_local_host.sql
Created January 12, 2016 01:01
Reemplazar un site url viejo por una nuevo ya sea porque se hizo un deploy de localhost al site online o porque se cambio de dominio. Fixing Images and Broken Links by updating Paths url: http://www.wpbeginner.com/wp-tutorials/how-to-move-wordpress-from-local-server-to-live-site/
UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yourlivesite.com/');
.styled-select{
width: 100%;
overflow: hidden;
background: url('images/la-plaza-de-tu-mascota/arrow-dropdown.png') no-repeat right transparent;
border: 1px solid #ccc;
}
.styled-select select {
background: transparent;
width: 100%;
border: 0;
@pablocattaneo
pablocattaneo / remove_main_content_editor_secific_page.php
Created January 20, 2016 05:04
Remove de main content editor for a specific page in Wordpress
function remove_editor() {
if (isset($_GET['post'])) {
$id = $_GET['post'];
$template = get_post_meta($id, '_wp_page_template', true);
if($template == 'template_name.php'){
remove_post_type_support( 'page', 'editor' );
}
}
}
@pablocattaneo
pablocattaneo / remove_emojis.php
Created January 22, 2016 04:54
How to remove the WordPress emoji code In functions.php (your WordPress theme) Add the following lines Resource: http://www.denisbouquet.com/remove-wordpress-emoji-code/
// REMOVE WP EMOJI to ensure CSS files are downloaded in parallel
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@pablocattaneo
pablocattaneo / cms_block_phtml.php
Created January 26, 2016 20:11
Add cms block to phtml
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('huellas-tomates-slider')->toHtml(); ?>
@pablocattaneo
pablocattaneo / custom_field_array.php
Created February 3, 2016 16:28
Devuelve todos los custom field que tengan la misma Key. Return all custom fielnd with same key value.
<?php
$listItem="keyName"; // EL nombre del custom field tal como está en adminstrador ejemplo: canción
$listItem = get_post_meta($post->ID, $listItem, false); // La propiedad false convierte la respuesta en array
foreach ($listItem as &$valor) {
echo $valor . "<br/>";
}
?>
@pablocattaneo
pablocattaneo / custom_excerpt.php
Created February 4, 2016 15:11
Crea un custom excerpt que corta el contenido por cantidad de caracteres, esta función tiene que escribirse en function.php Create a custom excerpt that cuts the content acording the number of charcaters define, Source: http://smallenvelop.com/4-ways-to-limit-post-excerpt-length-in-wordpress/
<?php
function get_excerpt(){
$excerpt = get_the_content();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, 50); // characters number
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
$excerpt = $excerpt.'... <a href="'.$permalink.'">more</a>';
@pablocattaneo
pablocattaneo / thumbnail_custom_size.php
Last active September 16, 2017 00:07
Add custom thubmnail image size. If the image size is bigger than size define in the custom size it will be cut and center.
<?php add_image_size( 'custom-size', 220, 180, true ); // 220 pixels wide by 180 pixels tall, hard crop mode
@pablocattaneo
pablocattaneo / new_gist_file_0
Created February 11, 2016 19:25
Cambiar la url base segura e insegura. Change the url base secure and unsecure from database source: https://docs.nexcess.net/article/how-to-change-magento-base-urls.html
From the menu on the left, click Hosting Features > MySQL > PhpMyAdmin (Figure 4).
You will see the main menu for phpMyAdmin. On the left side of the screen, locate and click the name of the Magento database corresponding to URL you want to change.
Figure 5. Magento database selection.
You will see a list of all the tables in the database in alphabetical order. Search for the core_config_data table and click Browse (Figure 6).
Figure 6. List of tables and core_config_data table.