This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Loop Add to Cart. | |
* | |
* Template with quantity and ajax. | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. | |
global $product; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Example meta box field | |
$featured_categories->add_field( array( | |
'name' => __( 'Featured categories', 'iweb' ), | |
'id' => 'featured_categories', | |
'type' => 'pw_multiselect', | |
'options' => iweb_get_cmb_options_array_tax( 'category' ), | |
) ); | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set teamIdsToExclude = ['and'] %} | |
{% for excerpt in craft.entries.section('team').limit(12) %} | |
{% set teamIdsToExclude = teamIdsToExclude|merge([excerpt.id]) %} | |
{% endfor %} | |
{# Convert the teamIdsToExclude array into a comma separated list #} | |
{% set teamIdsToExcludeString = teamIdsToExclude|join(', not ') %} | |
{% for excerpt in craft.entries.section('team').id(teamIdsToExcludeString) %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_maybe_woocommerce_variation_permalink( $permalink ) { | |
if ( ! is_search() ) { | |
return $permalink; | |
} | |
// check to see if the search was for a product variation SKU | |
$sku = get_search_query(); | |
$args = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /* | |
Takes a product ID and returns an array that includes all types of variations of the product, and the attributes of that variation. | |
Variations are normally returned as a term object. They belong to the original product ID and the taxonomy name is equal to the attribute name. | |
If a custom variation is provided instead of a term object, the variation will simply be a string of the option's name. | |
Example return result is given below. This is a single product with one attribute and two different variations. | |
Array ( | |
[pa_oregon-training-classes] => Array ( | |
[attribute] => Array ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// lets talk variations here | |
$available_variations = $product->get_available_variations(); | |
foreach($available_variations as $prod_variation) { | |
$post_id = $prod_variation['variation_id']; | |
$post_object = get_post($post_id); | |
// do what you like with the post object here | |
// you can add the variation to the product cart by linking to ?add-to-cart={variation_id}&quantity=xxx | |
echo $post_object->post_title; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Display variation dropdown as table | |
function woocommerce_variable_add_to_cart() { | |
global $product, $post; | |
$variations = $product->get_available_variations(); | |
foreach ($variations as $key => $value) { | |
?> | |
<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"method="post" enctype='multipart/form-data'> | |
<input type="hidden" name="variation_id" value="<?php echo $value['variation_id']?>" /> | |
<input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" /> | |
<?php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('add_meta_boxes', 'yoast_is_toast', 99); | |
function yoast_is_toast(){ | |
//capability of 'manage_plugins' equals admin, therefore if NOT administrator | |
//hide the meta box from all other roles on the following 'post_type' | |
//such as post, page, custom_post_type, etc | |
if (!current_user_can('activate_plugins')) { | |
remove_meta_box('wpseo_meta', 'post_type', 'normal'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rewrites for Yoast SEO XML Sitemap | |
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last; | |
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; |