Skip to content

Instantly share code, notes, and snippets.

View mrgrt's full-sized avatar
🐢
Slow and steady

mrgrt

🐢
Slow and steady
View GitHub Profile
@mrgrt
mrgrt / functions.php
Last active July 15, 2018 13:50
Change "choose an option" in WooCommerce - simple
<?php
//Customise the dropdown 'choose an option'
add_filter('woocommerce_dropdown_variation_attribute_options_args', 'wcvdc_dropdown_choice', 10);
// Displays the custom "Choose an option" on the front end
function custom_dropdown_choice( $args ){
$args['show_option_none'] = "Select an option:";
@mrgrt
mrgrt / functions.php
Created May 10, 2018 18:43
Change "choose an option" in WooCommerce.
<?php
//Customise the dropdown 'choose an option'
add_filter('woocommerce_dropdown_variation_attribute_options_args', 'wcvdc_dropdown_choice', 10);
// Displays the custom "Choose an option" on the front end
function custom_dropdown_choice( $args ){
global $product;
<?php
function add_pages_to_dropdown( $pages, $r ){
if ( ! isset( $r[ 'name' ] ) )
return $pages;
if ( 'page_on_front' == $r[ 'name' ] ) {
$args = array(
'post_type' => 'post'
@mrgrt
mrgrt / functions.php
Last active May 6, 2018 20:20
Set post as front page.
<?php
add_action('pre_get_posts', function($q){
// Check to see if static page is set for the homepage.
if (!is_admin() && $q->is_main_query() && 'page' === get_option('show_on_front')) {
//Determine if current post is homepage
if ($q->get("page_id") == get_option("page_on_front")) {
@mrgrt
mrgrt / primary_category.php
Created March 8, 2018 16:14
Get Primary Category - WordPress (Yoast)
<?php
function get_primary_cat_id($id=Null){
if(!$id){
$id = get_the_ID();
}
if(get_post_type($id)!="post"){
$meta_value = "_yoast_wpseo_primary_" . get_post_type($id). "_cat";