We're merging with GenerateBlocks! Learn more here.

[Resolved] WPML and "Read more…" translation problems

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support WPML and "Read more…" translation problems

Viewing 5 posts - 31 through 35 (of 35 total)
  • Author
    Posts
  • #21832
    Samuel
    Participant

    Hi Tom,

    This is working for styling issue perfectly, thanks !

    But this function is still breaking the job we’ve done together regarding the “redirecting to custom url” thing (reply #20708)

    #21898
    Tom
    Keymaster

    Ah, so use the code we came up with there, but replace this:

    $settings['read_more_text']

    With this:

    __( 'Read more', 'wp-show-posts' )

    #21946
    Samuel
    Participant

    Hi Tom,

    Thanks again for your time, your support is amazing, but it’s not working. Here is the entire hook we are using combining custom redirection + read more translation :

    <?php
    
    add_filter( 'wpsp_title_href', function( $href ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return $custom_url;
        }
    
        return $href;
    } );
    
    add_filter( 'wpsp_image_href', function( $href ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return $custom_url;
        }
    
        return $href;
    } );
    
    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return sprintf(
                '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
                the_title_attribute( 'echo=0' ),
                esc_url( $custom_url ),
                __( 'Read more', 'wp-show-posts' ),
                esc_attr( $settings['read_more_class'] )
            );
        }
    
        return $output;
    }, 10, 2 );
    
    add_filter( 'wpsp_terms_output', function( $output ) {
        return strip_tags( $output );
    } );
    
    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
        return sprintf(
            '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
            the_title_attribute( 'echo=0' ),
            esc_url( get_permalink() ),
            __( 'Voir les tarifs', 'wp-show-posts' ),
            esc_attr( $settings['read_more_class'] )
        );
    }, 10, 2 );
    
    ?>
    #21950
    Samuel
    Participant

    Oh sorry, my bad, with the confusion of the our 2 different issues (redirection and translation) there was 2 functions conflicting, now it’s working, and here is the final word :

    <?php
    
    add_filter( 'wpsp_title_href', function( $href ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return $custom_url;
        }
    
        return $href;
    } );
    
    add_filter( 'wpsp_image_href', function( $href ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return $custom_url;
        }
    
        return $href;
    } );
    
    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
        $custom_url = get_post_meta( get_the_ID(), 'url-booking', true );
    
        if ( $custom_url ) {
            return sprintf(
                '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
                the_title_attribute( 'echo=0' ),
                esc_url( $custom_url ),
                __( 'Voir les tarifs', 'wp-show-posts' ),
                esc_attr( $settings['read_more_class'] )
            );
        }
    
        return $output;
    }, 10, 2 );
    
    add_filter( 'wpsp_terms_output', function( $output ) {
        return strip_tags( $output );
    } );

    ?>`

    #22000
    Tom
    Keymaster

    Glad it’s working now 🙂

Viewing 5 posts - 31 through 35 (of 35 total)
  • You must be logged in to reply to this topic.