• Resolved ernexto

    (@ernexto)


    Hello, first of all many compliments for your excellent plugin. Now I have a simple question. How can I change this text to only print “Prezzo max € 536”? Please, see this image: https://imgur.com/bku1VOC

    I searched the forum and saw that you answered a similar question (by a russian user) pasting some snipped-code… I tried that code but it doesn’t seem to work for me.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author stepasyuk

    (@stepasyuk)

    Hello @ernexto

    Thank you for your warm words about the plugin. I think plugin reviews is the best place for such words ??

    Use this code, replace it with your $meta_key if you use different, but not the _price

    add_filter( 'wpc_filter_post_meta_num_term_name', 'wpc_custom_post_meta_num_term_name', 10, 2 );
    function wpc_custom_post_meta_num_term_name( $term_name, $entity_name ){
        $meta_key = '_price';
        if( $entity_name === $meta_key ){
            $term_name = str_replace( 'max prezzo_massimo', 'prezzo max €', $term_name );
            $term_name = str_replace( 'min prezzo_massimo', 'prezzo min €', $term_name );
        }
        return $term_name;
    }
    • This reply was modified 3 years, 3 months ago by stepasyuk.
    • This reply was modified 3 years, 3 months ago by stepasyuk.
    Thread Starter ernexto

    (@ernexto)

    Thank You @stepasyuk I will for sure leave the review! ??

    I tried the snipped you posted (using Code Snippets plugin) but it doesn’t seem to work. I have the same results as the previous picture.

    Please see my setting: https://imgur.com/JmULcd4

    Do I have to change something? Thanks

    Plugin Author stepasyuk

    (@stepasyuk)

    Okay, let me please know what the next code shows on the page with selected price:

    add_filter( 'wpc_filter_post_meta_num_term_name', 'wpc_custom_post_meta_num_term_name', 10, 2 );
    function wpc_custom_post_meta_num_term_name( $term_name, $entity_name ){
        $meta_key = '_price';
        if( $entity_name == $meta_key ){
            var_dump($term_name);
            $term_name = str_replace( 'max prezzo_massimo', 'prezzo max €', $term_name );
            $term_name = str_replace( 'min prezzo_massimo', 'prezzo min €', $term_name );
        }
        return $term_name;
    }

    BTW, try to place it in the fucntions.php file of the active theme.

    • This reply was modified 3 years, 3 months ago by stepasyuk.
    Thread Starter ernexto

    (@ernexto)

    Here is the output in the top:
    string(20) “Min prezzo_massimo 3” string(22) “Max prezzo_massimo 445” string(20) “Min prezzo_massimo 3” string(22) “Max prezzo_massimo 445” string(20) “Min prezzo_massimo 3” string(22) “Max prezzo_massimo 445”

    Plugin Author stepasyuk

    (@stepasyuk)

    @ernexto thank you. Try please this version of the code:

    add_filter( 'wpc_filter_post_meta_num_term_name', 'wpc_custom_post_meta_num_term_name', 10, 2 );
    function wpc_custom_post_meta_num_term_name( $term_name, $entity_name ){
        $meta_key = '_price';
        if( $entity_name === $meta_key ){
            $term_name = str_replace( 'Max prezzo_massimo', 'Prezzo max €', $term_name );
            $term_name = str_replace( 'Min prezzo_massimo', 'Prezzo min €', $term_name );
        }
        return $term_name;
    }
    • This reply was modified 3 years, 3 months ago by stepasyuk.
    Thread Starter ernexto

    (@ernexto)

    Yesss!!! It does work now! Thank you very much for your time @stepasyuk
    Five stars are coming your way ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to change price range filter result’ is closed to new replies.