First create global variables (in functions.php or as a mu-plugin):
<?php
/*
* CUSTOM GLOBAL VARIABLES
*/
function wtnerd_global_vars() {
<?php | |
/** | |
* Make Media attachments translatable with WPML | |
* | |
* Filter ACF images and galleries to switch attachment ids with their | |
* corresponding WPML translation. | |
*/ | |
add_filter( 'acf/load_value/type=gallery', 'my_acf_load_translated_attachment', 10, 3 ); | |
add_filter( 'acf/load_value/type=image', 'my_acf_load_translated_attachment', 10, 3 ); |
First create global variables (in functions.php or as a mu-plugin):
<?php
/*
* CUSTOM GLOBAL VARIABLES
*/
function wtnerd_global_vars() {
<?php | |
/*-----------------------------------------------------------------------------------*/ | |
// EXCERPT SIZE | |
/*-----------------------------------------------------------------------------------*/ | |
function get_excerpt() { | |
$output = substr(get_the_excerpt(), 0,85); | |
$output = apply_filters('wptexturize', $output); | |
$output = apply_filters('convert_chars', $output); | |
$output = $output; |
<?php | |
/*========================================= | |
Custom Submit Box | |
==========================================*/ | |
/** | |
* Loop throught custom post types and | |
* replace default submit box | |
* | |
* @since 1.0 | |
* |
<?php | |
// There are three options (that I know of) for automatically enabling a plugin | |
// in new sites. | |
// 1. Move the plugin from wp-content/plugins/ to wp-content/mu-plugins/ (MU = | |
// Must Use). But then it cannot be deactivated for any site. | |
// 2. Click "Network Activate" instead of "Activate" to enable it for all sites. | |
// I didn't want to use this though because I didn't want to affect existing |
<?php | |
add_filter( 'acf/load_field/name=flex_layout', __CLASS__ . '::craft_content_layouts' ); | |
static function craft_content_layouts( $field ) { | |
// Remove the layouts | |
// that are named in this list | |
$remove_list = [ | |
'paragraph', | |
'banner', |
/** | |
* You often need to get the content or title from a specific post. | |
* Sometimes, using a custom loop is the better option, but when you only need | |
* to get information from a specific post, there’s a better option | |
*/ | |
echo get_post_field('post_content', $post_id); |
/* | |
* Add our Custom Fields to simple products | |
*/ | |
function mytheme_woo_add_custom_fields() { | |
global $woocommerce, $post; | |
echo '<div class="options_group">'; | |
// Text Field |
<?php | |
// In a class constructor | |
$this->size_tax = wc_attribute_taxonomy_name( 'Size' ); | |
$this->color_tax = wc_attribute_taxonomy_name( 'Color' ); | |
// Insert the main product first | |
// It will be used as a parent for other variations (think of it as a container) | |
$product_id = wp_insert_post( array( |