Skip to content

Instantly share code, notes, and snippets.

@corilam
corilam / 0_reuse_code.js
Created April 10, 2016 08:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@corilam
corilam / functions.php
Created July 30, 2016 14:49
Woocommerce Custom Tabs with Advanced Custom Fields
// This version works with an ACF with the name 'new'
// 1.Displays the tab on every product page
add_filter( 'woocommerce_product_tabs', 'woo_new_tab' );
function woo_new_tab( $tabs ) {
// Adds the new tab
$tabs['new'] = array(
'title' => __( 'New', 'woocommerce' ),
'priority' => 20,
'callback' => 'woo_new_tab_content'
);
@corilam
corilam / style.css
Created September 6, 2016 04:33
Center Tabs in Foundation 6
.tabs-title {
float:none !important;
display:inline-block;
}
.tabs {
text-align:center;
}
@corilam
corilam / functions.php
Last active November 20, 2016 08:30
WPML Hide Languages in Custom Switcher with CSS
//Language Switcher
add_filter('wp_nav_menu_items', 'new_nav_menu_items', 10, 2);
function new_nav_menu_items($items, $args) {
//Places the Language switcher in theme menu location 'languages'
if (function_exists('icl_get_languages') && $args->theme_location == 'languages') {
$languages = icl_get_languages('skip_missing=0');
//Remove current language and assign language code name class to li item
if(!empty($languages)){
foreach($languages as $l){
if(!$l['active']){
@corilam
corilam / page.php
Created December 2, 2016 14:31
WPML Get home url of current language
<?php $my_home_url = apply_filters('wpml_home_url', get_option('home')); ?>
<a href="<?php echo $my_home_url; ?>">Home</a>
@corilam
corilam / page.php
Created April 27, 2017 08:44
Wordpress useful snippets
// Site URL
<?php get_site_url(); ?>
// Dynamic Footer Date
<?php the_date('Y'); ?>
// Featured Image as Background Image
<style>.project-card-image{width:200px;height:200px;background-position:center}</style>
<?php $projectbg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'home-campaigns' );?>
<div class="project-card-image" style="background-image: url('<?php echo $projectbg['0'];?>');"></div>
@corilam
corilam / footer.php
Last active July 25, 2017 08:53
Slide up newsletter subscribe
@corilam
corilam / page.php
Created August 24, 2017 13:21
Wordpress Background Image Using Featured Image
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'slideshow' );?>
<div style="background-image: url('<?php echo $thumb['0'];?>');" class="large-header-image">
</div>
@corilam
corilam / functions.php
Last active November 7, 2019 21:52
Exclude logged in users from Google Analystics
add_action('wp_head','ga_header', 20);
function ga_header() {
if ( !is_user_logged_in()) { ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
@corilam
corilam / custom-collection-plugin.php
Last active February 16, 2021 15:27
Object Custom Post Type
<?php
/**
* Plugin Name: Custom Collection Plugin
* Plugin URI: https://thedigitalconcern.com
* Description: Creates a collection custom post type called Objects.
* Version: 1.0
* Requires at least: 5.2
* Requires PHP: 7.2
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html