Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
jamiemitchell / WordPress - Custom Post Type and Custom Taxonomy.php
Created May 1, 2017 11:02
Custom Post Type and Taxonomy registration example for WordPress
<?php
/* Register Custom Post Type */
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'case-study',
array(
'labels' => array(
'name' => __( 'Case Studies' ),
@jamiemitchell
jamiemitchell / functions.php
Last active December 22, 2021 18:44
Add a Woocommerce cart icon with count in Genesis
<?php //* Do not include this opening php tag
//* Add Cart icon and count to header if WC is active
add_action( 'genesis_header', 'jmd_wc_cart_count' );
function jmd_wc_cart_count() {
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
$count = WC()->cart->cart_contents_count;
@jamiemitchell
jamiemitchell / style.css
Created May 28, 2013 23:58
Center the simple social icons for mobile devices, this needs to go in your media queries (portrait) of your style.css
/* Center simple social icons
-------------------------------------------- */
body .simple-social-icons .alignleft,
body .simple-social-icons .alignright {
float: none;
text-align: center;
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
<!-- 0) Display Medium sized image floated right -->
http://sridharkatakam.com/how-to-display-featured-image-in-single-posts-in-genesis/
$image_args = array(
'size' => 'medium',
'attr' => array(
@jamiemitchell
jamiemitchell / add-an-id-to-site-inner.php
Created February 5, 2020 05:25 — forked from Lego2012/add-an-id-to-site-inner.php
Add an ID to .site-inner #wordpress #genesis
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add an ID to .site-inner
add_filter( 'genesis_attr_site-inner', 'custom_attributes_content' );
function custom_attributes_content( $attributes ) {
if ( is_singular('post' ) ) {
$attributes['id'] = 'site-inner';
}
@jamiemitchell
jamiemitchell / gist:27eca23f02f7db80ca39f05c0b64f906
Created January 26, 2020 02:25 — forked from davemac/gist:3484845
Check if ACF fields exists
<?php elseif ( has_post_thumbnail() ) :
$featured_image_link = ( get_field( 'featured_image_links_to' ) );
if ( $featured_image_link ) {
echo '<a href="'.get_permalink($post_object->ID) .'">';
if ( has_post_thumbnail()) { the_post_thumbnail( 'hero-image-medium', array( 'class' => 'large fx' ) ); }
echo '</a>';
} else {
the_post_thumbnail( 'hero-image-medium', array( 'class' => 'large fx' ) );
};
endif; ?>
@jamiemitchell
jamiemitchell / functions.php
Last active September 16, 2019 21:50
Conditionally remove/show the entire footer in Genesis.
<?php // Don't include this tag.
add_action ( 'genesis_meta', 'jm_remove_footer' );
/**
* Conditionally remove the entire footer.
*
* @link https://codex.wordpress.org/Conditional_Tags
*/
function jm_remove_footer() {
@jamiemitchell
jamiemitchell / genesis-searchwp-image-search.php
Created September 14, 2019 21:25 — forked from robneu/genesis-searchwp-image-search.php
Create a custom search template to display custom search results using SearchWP and the Genesis Framework.
<?php
/**
* This file adds the SearchWP Images template to your theme.
*
* Template Name: SearchWP Images
*
* @author Robert Neu
* @package Genesis
* @subpackage SearchWP
*/
@jamiemitchell
jamiemitchell / add-to-woocommerce-additional-info-tab-single-product.php
Created December 28, 2017 09:45 — forked from ben-heath/add-to-woocommerce-additional-info-tab-single-product.php
Add content to WooCommerce Additional Information Tab on Single Products
<?php
// This code should be added to the functions.php file of the child theme
// Add custom info to Additional Information product tab
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product;
$tabs['additional_information']['callback'] = 'custom_function_name'; // this is the function name which is included below
return $tabs;
}
@jamiemitchell
jamiemitchell / gutenberg-sample-content.html
Created August 28, 2019 22:22 — forked from mailenkno/gutenberg-sample-content.html
WordPress Gutenberg Sample Content
<!-- wp:paragraph {"align":"center","customTextColor":"#000000","backgroundColor":"very-light-gray","fontSize":"small"} -->
<p style="color:#000000;text-align:center" class="has-background has-small-font-size has-very-light-gray-background-color">Gutenberg Sample Content.<br/>Put together with ❤️ by <a href="https://artisanthemes.io/">Artisan Themes</a>.</p>
<!-- /wp:paragraph -->
<!-- wp:heading {"level":1} -->
<h1>This is a heading (H1)</h1>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>This is a heading (H2)</h2>