Skip to content

Instantly share code, notes, and snippets.

@deeman
deeman / wc-noindex-orderby
Created April 23, 2018 22:16
SEO & WooCommerce - Prevent indexing "Order by"
add_action( 'wp_head', 'cp_prevent_indexing_orderby' );
if(!function_exists('cp_prevent_indexing_orderby')){
function cp_prevent_indexing_orderby () {
if (isset($_GET['orderby'])){
echo '<meta name="robots" content="noindex, nofollow">';
}
}
}
@deeman
deeman / admin-widget-areas.php
Created August 9, 2018 11:10
Unregister Widget Areas in Admin
/*
* Comment out the ones you want to keep. You will need some, but not all, for each project.
* Also, if you un-register then you can't use the_widget();
*/
add_action( 'widgets_init', 'cab_unregister_widgets', 10 );
/**
* Unregister Various Widgets
* Clean up your widgets.php page
* Single comment out the ones you want to keep
@deeman
deeman / genesis-before-footer.php
Last active August 9, 2018 11:14
Genesis: How to Create A widget area before footer
@deeman
deeman / functions.php
Created August 27, 2018 12:20
Genesis Framework - Modify read more link
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Modify the Genesis Franework read more link
add_filter( 'get_the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
return '<a class="more-link" href="' . get_permalink() . '">Continue Reading →</a>';
}
@deeman
deeman / functions.php
Last active January 11, 2019 12:48
Genesis: Enqueue Ion Icons In Genesis
add_action( 'wp_enqueue_scripts', 'load_ionicons' );
function load_ionicons() {
wp_enqueue_style( 'genesis-ionicons', '//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', array(), CHILD_THEME_VERSION );
}
@deeman
deeman / functions.php
Last active January 27, 2019 11:16
Enqueue the Dashicons script
//Enqueue the Dashicons script
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
function load_dashicons_front_end() {
wp_enqueue_style( 'dashicons' );
}
@deeman
deeman / remove-entry-title.php
Last active January 13, 2019 14:33
Genesis Framework - How to remove entry title
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Remove entry title in entry header (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
@deeman
deeman / functions.php
Last active February 8, 2020 16:02
Setup Google Analytics tracking via PHP-hook
//Add Google Analytics function
function google_analytics() {
include_once("analyticstracking.php");
}
//Add tracking action, set Google Analytics
add_action('wp_head', 'google_analytics');
@deeman
deeman / functions.php
Last active February 26, 2019 00:27
Admin Login to WooCommerce Product-area
// Login direct to the Product area in Admin Back-end
add_action( 'load-index.php', 'woo_direct_access_wp_dashboard_redirect' );
function woo_direct_access_wp_dashboard_redirect(){
wp_redirect( admin_url( 'edit.php?post_type=product' ) );
}
add_filter( 'login_redirect', 'woo_login_wp_dashboard_redirect', 9999, 3 );
function woo_login_wp_dashboard_redirect( $redirect_to, $request, $user ){
@deeman
deeman / functions.php
Last active February 27, 2019 11:10
Google Tag Manger (WordPress)
<!--
/* Step 1 - Get Your Google Tag Manager Code*/
-->
add_action('wp_head','my_analytics', 20);
function my_analytics() {
?>
<!-- Replace thi with first GTM code -->
<?php