Skip to content

Instantly share code, notes, and snippets.

@caralgar
caralgar / functions.php
Created June 13, 2018 09:35
Translate "Home" from breadcrumbs by yoast
<?php
function wpseo_translate_home_breadcrumb($links) {
if ( $links[0]['url'] == home_url('/') ) {
switch (ICL_LANGUAGE_CODE) {
case "es":
$links[0]['text'] = 'Inicio';
break;
default:
$links[0]['text'] = 'Home';
@caralgar
caralgar / functions.php
Last active May 10, 2018 21:23
Cómo cambiar el enlace y título del logotipo de WordPress en el Login
<?php
function my_login_logo_url() {
return home_url();
}
add_filter( 'login_headerurl', 'my_login_logo_url' );
function my_login_logo_url_title() {
return 'Mi título personalizado';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
@caralgar
caralgar / functions.php
Created May 10, 2018 21:21
Cómo cambiar el logotipo de Login en WordPress (II)
<?php
function calfaro_custom_login_logo() {
echo '
<style type="text/css">
.login h1 a {
background-image: url(' . get_stylesheet_directory_uri() . '/images/logo-calfaro.png);
padding-bottom: 0px;
width: 100%;
background-size: contain;
}
@caralgar
caralgar / functions.php
Created May 10, 2018 20:26
Cómo cambiar el logotipo de Login en WordPress
<?php
function mi_logo_personalizado() {
echo '
<style type="text/css">
.login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/login-logo.png);
}
</style>';
}
add_action( 'login_enqueue_scripts', 'mi_logo_personalizado' );
@caralgar
caralgar / file.js
Created January 9, 2018 12:31
Smooth scroll between pages
// smooth on load page
$(document).ready(function(){
var urlHash = window.location.href.split("#")[1];
if (urlHash.length > 0)
$('html,body').animate({
scrollTop: $('#' + urlHash).offset().top - 150
}, 1000);
});
@caralgar
caralgar / single.php
Created September 27, 2017 08:08
Show MAIN category (YOAST)
<?php
// SHOW YOAST PRIMARY CATEGORY, OR FIRST CATEGORY
$category = get_the_category();
$useCatLink = true;
// If post has a category assigned.
if ($category){
$category_display = '';
$category_link = '';
if ( class_exists('WPSEO_Primary_Term') )
{
@caralgar
caralgar / functions.php
Last active June 13, 2017 07:29
Do not texturize the "myshortcode" contents
<?php
/*
* https://codex.wordpress.org/Plugin_API/Filter_Reference/no_texturize_shortcodes
*/
add_filter( 'no_texturize_shortcodes', 'shortcodes_to_exempt_from_wptexturize' );
function shortcodes_to_exempt_from_wptexturize( $shortcodes ) {
$shortcodes[] = 'myshortcode';
return $shortcodes;
@caralgar
caralgar / functions.php
Created December 27, 2016 08:50
How to make child categories recognize parent's template on WordPress
/*
Credits: http://wordpress.stackexchange.com/questions/145805/how-to-make-child-categories-recognize-parents-template-displays
*/
function new_subcategory_hierarchy() {
$category = get_queried_object();
$parent_id = $category->category_parent;
$templates = array();
@caralgar
caralgar / style.css
Created April 7, 2016 06:18
How to solve the font weight bug on Firefox + OSX
* {-moz-osx-font-smoothing: grayscale;}
@caralgar
caralgar / scrips.js
Created March 31, 2016 10:04
Swap items order on HTML for responsive
$(window).resize(function() {
if ($(window).width() < 768) {
$('#content').insertBefore('#sidebar');
}
else
$('#sidebar').insertBefore('#content');
});