julio 2020

Working with the WordPress user meta query

$args = array(
    'meta_query' => array(
        'relation' => 'AND',
            array(
                'key'     => 'occupation',
                'value'   => 'developer',
                 'compare' => 'LIKE' // any value that contains developer
            ),
            array(
                'key'     => 'billing_country',
                'value'   => 'United States',
                 'compare' => '='
            ),
            array(
                'key'     => 'experience',,
                'value'   => '5',
                 'compare' => '>='
            )
    )
);
 
$user_query = new WP_User_Query( $args );

Visto en https://usersinsights.com/wordpress-user-meta-query/

Working with the WordPress user meta query Leer más »

Toolset: Mostrar relevancia de los resultados

add_shortcode( 'show_results_relevance', 'show_results_relevance_func');
function show_results_relevance_func($atts) {
    // get the searched terms for main ingredients
    $searched_recipe_main_ingredient = do_shortcode('[wpv-search-term param="wpv-main-ingredient"]');
    if(!empty($searched_recipe_main_ingredient))
    {
        $searched_recipe_main_ingredient_arr = explode(", ", $searched_recipe_main_ingredient);
        // count of searched main ingredients
        $searched_recipe_main_ingredient_count = count($searched_recipe_main_ingredient_arr);
  
        // get attached main ingredients for current post
        $attached_main_ingredients = do_shortcode("[wpv-post-taxonomy type='main-ingredient' format='name' separator=', ']");
  
        if(!empty($attached_main_ingredients))
        {   
            $attached_main_ingredients_arr = explode(", ", $attached_main_ingredients);
             
            // count of common ingredients which were searched and are also attached
            $matched_main_ingredients = count(array_intersect($searched_recipe_main_ingredient_arr,$attached_main_ingredients_arr));        
        }
        else
        {
            $matched_main_ingredients = 0;
        }
  
    }
    else
    {
        $searched_recipe_main_ingredient_count = 0;
        $matched_main_ingredients = 0;
    }
  
 
 
 
    return ($matched_main_ingredients/$searched_recipe_main_ingredient_count*100);
 
}

Visto en Toolset

Toolset: Mostrar relevancia de los resultados Leer más »

Scroll al inicio

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.