Skip to content

Instantly share code, notes, and snippets.

View IacopoC's full-sized avatar
🎯
Crunch mode

Iacopo C IacopoC

🎯
Crunch mode
View GitHub Profile
@IacopoC
IacopoC / trash-wp.php
Last active January 19, 2017 14:16
Trash time constant in WordPress
<?php define('EMPTY_TRASH_DAYS', 30); ?>
@IacopoC
IacopoC / ga-tracking-wp.php
Last active April 18, 2017 10:02
Google analytics tracking code snippet in functions.php WordPress
<?php add_action('wp_head', 'add_google_analytics');
function add_google_analytics() {
// Insert your GA code here
}
<?php capital_P_dangit( $text ); ?>
@IacopoC
IacopoC / woocommerce_check_cart_items_hook
Created March 4, 2017 13:17
WooCommerce hook that checks number of items in the cart
<?php do_action( 'woocommerce_check_cart_items' ); ?>
<?php
// return true if we are in the cart page
is_cart();
// return true if we are in the checkout page
is_checkout();
@IacopoC
IacopoC / Wc add notice for errors
Created March 4, 2017 13:25
Function useful to display error notice in WooCommerce
<?php
// Wc add notice can be used to create error, notice or success messages in WooCommerce. In this case we see error notice.
wc_add_notice( $message, $notice_type = 'error' );
@IacopoC
IacopoC / enqueue-css.php
Created April 15, 2017 19:32
Enqueue Css in WordPress plugin
/**
* Enqueue css
**/
function load_custom_wp_admin_style() {
wp_register_style( 'style.css', plugins_url('/css/style.css', __FILE__), false, '1.0.0' );
wp_enqueue_style( 'style.css' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
@IacopoC
IacopoC / Acf-loop.php
Last active March 16, 2019 21:30
ACF secondary loop news post type
<?php
$posts = get_posts(array(
'posts_per_page' => 3,
'post_type' => 'news'
));
if( $posts ): ?>
@IacopoC
IacopoC / acf-loop-taxonomy.php
Last active March 16, 2019 21:30
ACF loop through news taxonomy
<?php
$terms = get_the_terms( $post->ID, 'area');
$postid = get_the_ID();
foreach ($terms as $term) {
$posts = get_posts(array(
'posts_per_page'=> -1,
<?php
// enqueue font awersome from local css folder
function enqueue_fontawersome_stylesheets(){
wp_enqueue_style('font-awesome', get_stylesheet_directory_uri() . '/css/font-awesome.css');
}
add_action('wp_enqueue_scripts','enqueue_fontawersome_stylesheets');