add_menu_page (
string $page_title,
string $menu_title,
string $capability,
string $menu_slug,
callable $function = '',
string $icon_url = '',
int $position = null
);
/**
* Изменить текст на странице архива категории
*/
function woo_shop_category_custom_cart_button_text() {
if( is_product_category( 'category-slug' ) ) {
return __( 'Sign up', 'woocommerce' );
}
}
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_shop_category_custom_cart_button_text' );
/**
* Изменить текст на страничке товара
*/
function woo_custom_cart_button_text() {
if( has_term( 'category-slug', 'product_cat', $post ) ) {
return __( 'Sign up', 'woocommerce' );
// Дополнено автором вопроса:
} else {
return __( 'Add to cart', 'woocommerce' );
}
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );
function pss_wrap_nav_item( $title, $item ) {
if( in_array( 'item-wrap', $item->classes ) ) {
$title = '<span class="item-wrap has-effect">' . $title . '</span>';
}
return $title;
}
add_filter( 'nav_menu_item_title', 'pss_wrap_nav_item', 10, 2 );
/**
* Disable Emoji support introduced in WP 4.2
*/
function pss_disable_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
}
add_action( 'init', 'pss_disable_emoji' );
function your_function_name( $query ) {
if( $query->is_main_query() && $query->is_category( 'your_category' ) ) {
$query->set( 'posts_per_page' => 3 );
}
}
add_action( 'pre_get_posts', 'your_function_name' );
if( ! empty( get_post_meta( $post->ID, 'value', true ) ) ) {
echo get_post_meta($post->ID, 'value', true);
}
if( ! empty( trim( get_post_meta( $post->ID, 'value', true ) ) ) ) {
echo get_post_meta($post->ID, 'value', true);
}
The problem with using $field_name is that if the reference does not already exist, ACF will not be able to find the field object and will not be able to save the value. This situation would occur if you had used code to insert a post.