$need = explode( ',', $value ); // $value - значение вашего поля
// В массив параметров запроса добавить примерно такое
'meta_query' = [
[
'key' => 'key_name',
'value' => $need,
'compare' => 'LIKE'
]
] /**
* @param $redirect_to
* @param $request
* @param $user
*
* @return false|string
*/
function wpp_user_redirect( $redirect_to, $request, $user ) {
$user_id = get_current_user_id();
$page = get_user_meta( $user_id, 'field_key', true );
if ( ! empty( $page ) ) {
return get_the_permalink( (int) $page );
}
return $redirect_to;
}
add_filter( 'login_redirect', 'redirect_admin', 10, 3 );/**
* Split Product quantities in cart
* @param $cart_item_data
* @param $product_id
*
* @return mixed
*/
function wpp_only_one_product_per_row( $cart_item_data, $product_id ){
$cart_item_data['unique_key'] = uniqid();
return $cart_item_data;
}
add_filter( 'woocommerce_add_cart_item_data', 'wpp_only_one_product_per_row', 10, 2 );
add_filter( 'woocommerce_is_sold_individually', '__return_true' ); function wp_code() {
if ( is_singular() ) :
global $post;
$meta = get_post_meta( $post->ID, 'field_key', true );
if ( ! empty( $meta ) ) {
wp_enqueue_script( 'bla-bla-bla', get_template_directory_uri() . 'js/js_code.js' );
wp_enqueue_style( 'bla-bla-bla', get_template_directory_uri() . 'css/style.css' );
}
endif;
}
add_action( 'wp_enqueue_scripts', 'wp_code' ); <?php the_post_thumbnail('post-thumbnail', array('class' => 'my-class')); ?> mb_substr($post->post_title, 0, 1, 'utf-8'); function wpp_bt_shop_by_menu_items() {
if ( false === ( $html = get_transient( 'wpp_bt_shop_by_nav' ) ) ) {
$html = '';
$locations = get_nav_menu_locations();
if ( $locations && isset( $locations['shop_by'] ) ) :
$menu = wp_get_nav_menu_object( $locations['shop_by'] );
$menu_items = wp_get_nav_menu_items( $menu );
foreach ( $menu_items as $menu_item ):
$term = $menu_item->type === 'taxonomy' ? get_term( $menu_item->object_id ) : null;
$html .= wpp_bt_crate_items_list( $term, $menu_item );
endforeach;
endif;
set_transient( 'wpp_bt_shop_by_nav', $html, 24 * HOUR_IN_SECONDS );
}
return apply_filters( 'wpp_bt_shop_by_nav_items', $html );
}
/**
* Product cat naw menu item
*
* @param $term
* @param $menu_item
*
* @return string
*/
function wpp_bt_crate_items_list( $term, $menu_item) {
$html = '';
if ( $menu_item === null || ( $menu_item !== null && $menu_item->menu_item_parent == 0 ) ) {
if ( $menu_item === null || ( $menu_item !== null && $menu_item->object === 'product_cat' ) ) {
if ( wpp_instock_product_count_in_term( $term->term_id ) > 0 || ( $menu_item->object_id === BT_LATEST_PRODUCT_TERM ) ) {
$children = get_categories(
array(
'hide_empty' => true,
'taxonomy' => 'product_cat',
'parent' => $term->term_id
)
);
$class = count( $children ) > 0 ? 'has-child' : 'cat-no-child';
$title = $menu_item ? $menu_item->title : $term->name;
$html .= sprintf( '<li class="cat-item cat-item-%s %s">', $term->term_id, $class );
$html .= sprintf( '<a href="%1$s" title="%2$s">%2$s</a>', get_term_link( $term->term_id ), $title );
if ( count( $children ) > 0 ) {
$html .= '<ul class="children">';
foreach ( $children as $child ) {
if ( $child->count > 0 ) {
$html .= wpp_bt_crate_items_list( $child, null );
}
}
$html .= '</ul>';
}
$html .= '</li>';
}
} else if ( $menu_item->object == 'custom' ) {
$children = get_menu_item_children(
array(
'parent' => $menu_item->ID
)
);
$class = count( $children ) > 0 ? 'has-child' : 'cat-no-child';
$html .= sprintf( '<li class="cat-item cat-item-%s %s">', $menu_item->ID, $class );
$html .= sprintf( '<a href="%1$s%2$s" title="%3$s">%3$s</a>', get_home_url(), $menu_item->url, $menu_item->title );
if ( count( $children ) > 0 ) {
$html .= '<ul class="children">';
foreach ( $children as $child ) {
$html .= sprintf( '<li class="cat-item cat-item-%s cat-no-child">', $child->ID );
$html .= sprintf( '<a href="%1$s%2$s" title="%3$s">%3$s</a>', get_home_url(), $child->url, $child->title );
}
$html .= '</ul>';
}
$html .= '</li>';
}
}
return $html;
}