Skip to content

Instantly share code, notes, and snippets.

View aldolat's full-sized avatar
🤓
Happy in coding

Aldo Latino aldolat

🤓
Happy in coding
View GitHub Profile
@aldolat
aldolat / change_main_query.php
Last active December 3, 2016 09:13
Hide posts from a certain category in the main query.
<?php
/**
* Change the main query in order to hide posts from certain categories.
*
* @see https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
*/
function my_customized_query( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-10,-11,-325' );
}
@aldolat
aldolat / google_no_translate.js
Created June 17, 2016 19:32
Add an attribute via jQuery
jQuery(document).ready(function($){
$(".pis-thumbnail-link").attr('rel','bookmark nofollow');
});
@aldolat
aldolat / add_to_functions.php
Last active December 3, 2016 06:09
Add jQuery to functions.php file
<?php
function add_no_follow() {
wp_register_script( 'addnofollow', get_template_directory_uri() . '/js/google_no_translate.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'addnofollow' );
}
add_action( 'wp_enqueue_scripts', 'add_no_follow' );
@aldolat
aldolat / multipli_8_fino_500.php
Created February 13, 2016 11:52
Media dei multipli di 8 fino a 500 escluso
<?php
$a = 0;
$s = 0;
$ciclo = 0;
while ($a < 500) {
$a = $a + 8;
echo 'Multiplo di 8 = ' . $a . "<br>";
$s = $s + $a;
echo 'Somma dei multipli di 8 = ' . $s . "<br>";
$ciclo = $ciclo + 1;
@aldolat
aldolat / regola_udev.txt
Created November 25, 2015 18:15
Attivazione del supporto a U2F in Linux, utile per le chiavette YubiKey
#!/usr/bin/python
import re
import subprocess
import os
DEVICES = [
('0x1050', '0x0111', 'Yubico Yubikey NEO OTP+CCID'),
('0x1050', '0x0112', 'Yubico Yubikey NEO CCID'),
('0x1050', '0x0115', 'Yubico Yubikey NEO U2F+CCID'),
<?php
/* *** SITUATION ***
* We want to retrieve 3 posts and show the sticky posts on top.
* To make sticky posts work as expected, the 's' parameter must be not declared or should be NULL,
* otherwise the sticky posts won't appear on top of other posts.
*/
/* *** CASE 1 ***
* This code works as expected ('s' is not declared) and sticky posts appear on top:
*/
@aldolat
aldolat / load-scripts.php
Last active August 29, 2015 14:16
Load a custom javascript in a WordPress admin page
<?php
/**
* Load the Javascript file.
* The file will be loaded only in the widgets admin page.
*
* @since 1.25
*/
function pis_load_scripts( $hook ) {
if( $hook != 'widgets.php' ) {
return;
@aldolat
aldolat / convert-video
Created December 14, 2014 11:31
Convert from Full HD to mp4 HD. Make sure you have installed codecs from libavcodec-extra-54.
avconv -i input.MTS -s 1280x720 -b 8000k -r 30 output.mp4
@aldolat
aldolat / toto.php
Last active August 29, 2015 14:08
Versione migliorata.
<?php
function toto_rename( $action ) {
switch ( $action ) :
case 'home' :
$directory = '/';
break;
case 'it' :
@aldolat
aldolat / style.css
Created June 2, 2014 17:37
Create a child theme for WordPress
/*
Theme Name: {Child Theme name}
Theme URI: http: //www.example.com
Description: Child theme for {Parent theme name}
Author: {Author}
Author URI: http://www.example.com
Template: {name of the folder of the parent theme
Version: {version number}
*/