Skip to content

Instantly share code, notes, and snippets.

View AndreaBarghigiani's full-sized avatar
🔭
Looking for new opportunities

Andrea Barghigiani AndreaBarghigiani

🔭
Looking for new opportunities
View GitHub Profile
@AndreaBarghigiani
AndreaBarghigiani / loop.php
Created October 7, 2016 20:16
Esempio di WordPress Loop. Codice utilizzato in: https://skillsandmore.org/wordpress-loop-introduzione/
<?php query_posts( 'page_per_post=5&category_name=pippo' ); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
/* Codice da eseguire in caso di contenuto trovato */
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php
if( !function_exists( 'skam_setup') ){
function skam_setup(){
//Aggiungo il supporto al tag <title>
add_theme_support( 'title-tag' );
//Mostro il link del feed all'interno di <head>
add_theme_support( 'automatic-feed-links' );
<?php
if( !function_exists( 'skam_setup') ){
function skam_setup(){
}
}
add_action( 'after_setup_theme', 'skam_setup' );
function skam_widgets_init() {
@AndreaBarghigiani
AndreaBarghigiani / add-capability-to-role-user.php
Created July 3, 2016 09:31
Articolo: "Tutto quello che Devi Sapere sui Ruoli degli Utenti WordPress" (https://skillsandmore.org/wordpress-ruoli/)
<?php
//Per Ruolo
function aggiungi_capability() {
// prendo il ruolo author
$ruolo = get_role( 'author' );
//Aggiungo la mia Capability
$role->add_cap( 'aggiungi_prodotto' );
}
add_action( 'admin_init', 'aggiungi_capability');
@AndreaBarghigiani
AndreaBarghigiani / exp-action-hook.php
Last active August 21, 2016 14:58
Articolo: "Comprendiamo i WordPress Hook" https://skillsandmore.org/wordpress-hook/
<?php
function am_inserisci_autore() {
echo '<meta name="author" content="Andrea Barghigiani">\n';
} //fine am_inserisci_autore()
/* Action Hook */
add_action( 'wp_head', 'am_inserisci_autore' );
@AndreaBarghigiani
AndreaBarghigiani / functions.php
Created July 2, 2016 07:56
Articolo: "Crea un Child Theme WordPress e Scopri come ti sarà Utile"
<?php
add_action( 'wp_enqueue_scripts', 'carico_stili' );
function carico_stili(){
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
}
<?php
/**
* Genesis Framework.
*
* Questo file mi sara' utile per gestire il layout
* delle pagine contenenti i singoli corsi
*
* @package Genesis\Templates
* @author Codeat
* @license GPL-2.0+
@AndreaBarghigiani
AndreaBarghigiani / file.js
Created June 21, 2015 18:45
Scrivere codice jQuery in WordPress
/****************************************
Da inserire all'interno del file /percorso/file.js
*****************************************/
jQuery(document).ready(function($) {
$("#toggle_it").click(function () { $(".to_toggle").toggle(1000); });
$(".to_toggle").show();
$("#toggle_it1").click(function () { $(".to_toggle1").toggle(1000); });
@AndreaBarghigiani
AndreaBarghigiani / functions.php
Created June 21, 2015 18:44
Includere codice jQuery in WordPress
/****************************************
Da inserire all'interno del file functions.php
*****************************************/
if ( is_single( $id ) ){ //Sostituisci $id con l'ID della pagina specifica
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'mio-codice', get_template_directory_uri() . '/percorso/file.js', array( 'jquery' ) );
}
@AndreaBarghigiani
AndreaBarghigiani / test.php
Created January 20, 2015 12:09
Esercizio funzione conto_alla_rovescia()
<?php
//Manca proprio tutta la definizione della funzione
function conto_alla_rovescia( $int ){
$int = intval($int); //Mi assicuro che sia un intero
$m = $int; //Mi creo una variabile per contare i passi
for( $i = 0; $i < $m; $i++ ){
echo $int-- . "<br />";
}
}