If is empty field
ACF Functions
Si el camp està buit, mostra això altre
FIELD CODE…
<?php else: // field_name returned false ?>
OTHER CONTENT IF FIELD IS EMPTY
<?php endif; // end of if field_name logic ?>
Canvi de logo GeneratePress
GeneratePress Logo
A vegades necessites canviar el logo, per una altra combinació de colors o en negatiu…
add_filter( ‘generate_logo’, function( $logo ) {
// Return our category logo URL
if ( is_page( 666 ) ) {
return ‘https://tandem.blog/wp-content/uploads/2024/03/tandem_logo_blanc.svg’;
}
// Otherwise, return our default logo
return $logo;
} );
Canvia text botó “add to cart”
Functions WooCommerce
Personalitza el text dels botons d'”Afegeix a la cistella” de WooCommerce…
add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘woocommerce_add_to_cart_button_text_single’ );
function woocommerce_add_to_cart_button_text_single() {
return __( ‘EL TEU TEXT’, ‘woocommerce’ );
}
// Change add to cart text on product archives page
add_filter( ‘woocommerce_product_add_to_cart_text’, ‘woocommerce_add_to_cart_button_text_archives’ );
function woocommerce_add_to_cart_button_text_archives() {
return __( ‘EL TEU TEXT, ‘woocommerce’ );
}
Disable Cart, Checkout, Add Cart
Functions WooCommerce
Desactiva les funcions de botiga… per exemple per tenir un catàleg o perquè no vols que entrin comandes en algun moment.
add_action (‘init’, ‘tandem_woocommerce_close_mode’);
// Disable Cart, Checkout, Add Cart
function tandem_woocommerce_close_mode() {
remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
remove_action( ‘woocommerce_proceed_to_checkout’, ‘woocommerce_button_proceed_to_checkout’, 20 );
remove_action( ‘woocommerce_checkout_order_review’, ‘woocommerce_checkout_payment’, 20 );
add_action( ‘woocommerce_before_main_content’, ‘tandem_wc_shop_disabled’, 5 );
add_action( ‘woocommerce_before_cart’, ‘tandem_wc_shop_disabled’, 5 );
add_action( ‘woocommerce_before_checkout_form’, ‘tandem_wc_shop_disabled’, 5 );
}
// Show close Notice
function tandem_wc_shop_disabled() {
wc_print_notice( ‘Our Online Shop is Closed Today :)’, ‘error’);
}
Sticky Menu o Header
CSS GeneratePress
Fixar el menu
.main-navigation {
position: sticky;
top: 0;
z-index: 999;
}
.admin-bar .main-navigation {
top: 32px;
}
/* header */
.site-header {
position: sticky;
top: 0;
z-index: 999;
}
.admin-bar .site-header {
top: 32px;
}
GeneratePress Preferences
Functions GeneratePress
Amaga l’edició de preferències del tema a tots els usuaris
add_action( ‘after_setup_theme’,’tu_remove_gp_admin_menu’ );
function tu_remove_gp_admin_menu() {
remove_action(‘admin_menu’, ‘generate_create_menu’);
}
Desactiva gutenberg per a les entrades
Functions Gutenberg
Desactiva Gutenberg per a les entrades i per exemple amb ACF afegeixes camps personalitzats
function tandem_gutenberg_filter( $use_block_editor, $post_type ) {
if ( ‘post’ === $post_type ) {
return false;
}
return $use_block_editor;
}
add_filter( ‘use_block_editor_for_post_type’, ‘tandem_gutenberg_filter’, 10, 2 );
Desactivar editor Post Type
Functions
Amaga l’editor als tipus d’entrada
function my_remove_editor_from_post_type() {
remove_post_type_support( ‘post’, ‘editor’ );
remove_post_type_support( ‘page’, ‘editor’ );
}
Amagar editor principal de WooCommerce
Functions WooCommerce
Amagar l’editor principal de WooCommerce
function reset_editor(){
global $_wp_post_type_features;
$post_type=”product”;
$feature = “editor”;
if ( !isset($_wp_post_type_features[$post_type]) ){
}
elseif ( isset($_wp_post_type_features[$post_type][$feature]) )
unset($_wp_post_type_features[$post_type][$feature]);
}
add_action(“init”,”reset_editor”);
/* fi amaga editor principal de woocommerce */
Amagar opcions GP
Functions GeneratePress
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
remove_submenu_page( ‘themes.php’, ‘generate-options’ )