Skip to content

Instantly share code, notes, and snippets.

View yanceyk's full-sized avatar
🙃
I may be slow to respond.

Katrina Massey yanceyk

🙃
I may be slow to respond.
View GitHub Profile
@yanceyk
yanceyk / functions.php
Last active December 10, 2020 15:22
Prevent direct access via URL to a WordPress page
<?php
function prefix_no_direct_access() {
// Define Page URL for redirect.
$careers = get_permalink( get_page_by_title( 'Careers' ) );
// If this is not the Apply Now page, do nothing.
if( ! is_page( 'Apply Now' ) ) {
return;
}
@yanceyk
yanceyk / functions.php
Last active December 1, 2021 19:05
Move WooCommerce Store Notice ABOVE Page Header
<?php
/**
* Unregister WooCommerce Store Notice from 'wp_footer' action
*/
remove_action( 'wp_footer', 'woocommerce_demo_store' );
/**
* Register WooCommerce Store Notice to 'wp_body_open' action
*/
add_action( 'wp_body_open', 'woocommerce_demo_store' );
@yanceyk
yanceyk / functions.php
Last active January 26, 2022 19:26
Hide the price range for WooCommerce Variable Products and add 'from' text before the price.
<?php
//Customizes the 'from' text span.
add_filter( 'woocommerce_get_price_html_from_text', function( $html ) {
$from_HTML = str_replace(
_x( 'From:', 'min_price', 'textdomain' ) . ' </span>',
_x( 'from', 'min_price', 'textdomain' ) . '&nbsp; </span>',
$html
);
return $from_HTML;
}, 1 );
@yanceyk
yanceyk / functions.php
Last active January 28, 2022 23:47
Generates social sharing icons and links for single posts and WooCommerce products.
<?php
/**
* Generates social sharing icons and links for posts and products.
*
* For best results, make sure your site already includes OpenGraph support.
* @link https://ogp.me/
*/
function textdomain_social_sharing() {
//Set up the sharing links. We're keeping it basic - Facebook, Twitter, and Pinterest.