Skip to content

Instantly share code, notes, and snippets.

@galengidman
galengidman / functions.php
Last active August 29, 2015 13:57
register CTP with Dashicon
<?php
register_post_type('slide', array(
'label' => 'Slides',
'menu_icon' => 'dashicons-slides'
));
@galengidman
galengidman / functions.php
Last active June 6, 2021 12:10
Adding Static Menu Items to wp_nav_menu()
<?php
function my_nav_wrap() {
// default value of 'items_wrap' is <ul id="%1$s" class="%2$s">%3$s</ul>'
// open the <ul>, set 'menu_class' and 'menu_id' values
$wrap = '<ul id="%1$s" class="%2$s">';
// get nav items as configured in /wp-admin/
$wrap .= '%3$s';
@galengidman
galengidman / functions.php
Last active June 1, 2016 12:05
Adding WooCommerce cart link to wp_nav_menu()
<?php
function my_nav_wrap() {
$wrap = '<ul id="%1$s" class="%2$s">';
$wrap .= '%3$s';
$wrap .= '<li class="cart">';
$wrap .= '<a href="' . WC()->cart->get_cart_url() . '"> class="cart_totals">';
$wrap .= WC()->cart->get_cart_total();
$wrap .= '</a>';
$wrap .= '</li>';
@galengidman
galengidman / functions.php
Last active July 17, 2017 07:36
Check if WooCommerce cart has items, add link to have if it does
<?php
function my_nav_wrap() {
// checks if there is an item in the cart
// returns default items + cart link if there is
// returns default items if the cart is empty
if (sizeof(WC()->cart->get_cart()) != 0) {
$wrap = '<ul id="%1$s" class="%2$s">';
@galengidman
galengidman / index.php
Created May 9, 2014 22:18
A simple link to the WooCommerce cart
<a href="<?php echo WC()->cart->get_cart_url(); ?>">Cart</a>
@galengidman
galengidman / index.php
Created May 9, 2014 22:19
Using the cart total as the cart link text
<a href="<?php echo WC()->cart->get_cart_url(); ?>"><?php echo WC()->cart->get_cart_total(); ?></a>
@galengidman
galengidman / index.php
Last active August 29, 2015 14:01
Only display cart link if cart has items
<?php if (sizeof(WC()->cart->get_cart()) != 0) : ?>
<a href="<?php echo WC()->cart->get_cart_url(); ?>">
<span class="cart_totals"><?php echo WC()->cart->get_cart_total(); ?></span>
</a>
<?php endif; ?>
@galengidman
galengidman / index.php
Created May 9, 2014 22:26
Make sure cart total is can be updated as items are added live
<a href="<?php echo WC()->cart->get_cart_url(); ?>">
<span class="cart_totals"><?php echo WC()->cart->get_cart_total(); ?></span>
</a>
@galengidman
galengidman / mailchimp.html
Last active August 29, 2015 14:01
MailChimp form in simplest form
<form action="[ACTION]" method="post" target="_blank">
<input type="email" name="EMAIL" placeholder="Email&hellip;">
<input type="text" name="[BLOCKER]" tabindex="-1" style="display: none;">
<input type="submit" value="Subscribe">
</form>
@galengidman
galengidman / functions.php
Last active August 29, 2015 14:02
WordPress post type and taxonomy setup for a knowledge base.
<?php
add_action( 'init', 'kb_register_post_types' );
function kb_register_post_types() {
register_post_type( 'kb_article', array(
'labels' => array(
'name' => 'Articles',
'singular_name' => 'Article',
'menu_name' => 'Knowledge Base',