This file contains 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 | |
// Display sale items only when searching by /?sale=show | |
add_action('pre_get_posts','sale_items'); | |
function sale_items($query) { | |
if (!is_admin() && ( $query->is_post_type_archive( 'product' ) || $query->is_tax( get_object_taxonomies( 'product' ))) && isset($_GET['sale']) && $_GET['sale'] == 'show' ) { | |
$meta_query = array( | |
array( | |
'key' => '_sale_price', | |
'value' => 0, |
This file contains 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 | |
/** | |
* Plugin Name: Brand taxonomy | |
* Plugin URI: https://drivdigital.no | |
* Description: Force a brand taxonomy to thrive | |
* Version: 1.0.0 | |
*/ | |
class brand_taxonomy { | |
// Nope. brand is still a taxonomy |
This file contains 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 | |
/* Parse the video uri/url to determine the video type/source and the video id */ | |
function parse_video_uri( $url ) { | |
// Parse the url | |
$parse = parse_url( $url ); | |
// Set blank variables | |
$video_type = ''; | |
$video_id = ''; |
This file contains 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
$gravity_form_id = 6; // gravity form id, or replace {$gravity_form_id} below with this number | |
add_filter("gform_after_submission_{$gravity_form_id}", 'jdn_set_post_acf_gallery_field', 10, 2); | |
function jdn_set_post_acf_gallery_field($entry, $form) | |
{ | |
$gf_images_field_id = 42; // the upload field id | |
$acf_field_id = 'field_54804833b3067'; // the acf gallery field id | |
// get post |
This file contains 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 | |
add_action( 'init', function() { | |
ini_set( 'memory_limit', '2048M' ); | |
set_time_limit( 0 ); | |
$posts = get_posts( [ | |
'post_type' => 'product', | |
'posts_per_page' => -1 | |
] ); | |
$count = 0; |
This file contains 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
// This will make a new function called "get_the_slug()" which will get the page | |
// slug, for example, of the page is ...com/blog/news/story-name-here, then this | |
// will echo 'story-name-here'. I'm using this in WooCommerce for the product | |
// 360 images, because I need to rename each set of images so they become | |
// unique, I needed a way of getting separating them. The only drawback here, is | |
// that you need to know the slug before you make the images, AND if you rename | |
// that page, the images will break. SO. It's something that is experimental, | |
// but if monitored right, shouldn't be a problem! & | |
function get_the_slug( $id=null ){ |
This file contains 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 | |
/** | |
* Optimize WooCommerce Scripts | |
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 ); | |
function child_manage_woocommerce_styles() { | |
//remove generator meta tag | |
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); |
This file contains 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
<form role="search" method="post" class="search-form padding-4" action="<?php echo home_url( '/' ); ?>"> | |
<label> | |
<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span> | |
<input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search...', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" /> | |
<input class="post_type" type="hidden" name="post_type" value="frequent" /> | |
</label> | |
<input type="submit" class="search-submit button brand" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ) ?>" /> | |
</form> | |
<script type="text/javascript"> |
This file contains 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 | |
// Add the first gallery image to the item within the cateogry view. | |
// this hooks on to the content title before hook | |
function vakrerom_additional_image_on_category(){ | |
global $product; | |
$attachment_ids = $product->get_gallery_attachment_ids(); | |
if (!empty($attachment_ids)){ | |
foreach( array_slice( $attachment_ids , 0, 1) as $attachment_id ) { | |
$image_link = wp_get_attachment_url( $attachment_id ); ?> | |
<span class="image--lookbook"> |
This file contains 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 | |
if ( 'supersecret' == @$_GET['supersecret']) { | |
add_action( 'wp_footer', function() { | |
$ids = [2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2615, 2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2629, 2630, 2631, 2632, 2633, 2634, 2635, 2636, 2637, 2638, 2639, |
NewerOlder