Home Forums WoodMart support forum Line break in product titles

Line break in product titles

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #38281

    MoeMauphie
    Participant

    Hi there,

    I’m using the following code to add a line break in the product titles and it works like a charm almost everywhere except in Ajax search results in which it doesn’t output <br /> properly. Actually it converts the tag <br /> to < br <.

    Could you please help me with this problem?

    add_filter( 'the_title', 'custom_the_title', 10, 2 );
    function custom_the_title( $title, $post_id ){
        $post_type = get_post_field( 'post_type', $post_id, true );
        if( $post_type == 'product' || $post_type == 'product_variation' )
            $title = str_replace( '|', '<br />', $title ); // we replace '|' by '<br/>':
        return $title;
    }

    Regards

    Attachments:
    You must be logged in to view attached files.
    #38288

    MoeMauphie
    Participant

    Sorry I was not able to edit my previous post, those characters converted to the tag after I submitted my post.

    Actually it converts < to & l t ; (I had to enter a space between these characters in order to prevent them from rendering together)

    #38295

    Artem Temos
    Keymaster

    Yes, this area doesn’t support BR tag and you can do this customizing our JS files only. You need to disable JS minification in Theme Settings -> Performance and edit the file js/functions.js. Find this code https://gyazo.com/fdb35d029f3324728e4a02465cba8485 and replace with this one

    returnValue += '<div class="suggestion-title product-title">' + suggestion.value + '</div>';

    #38468

    MoeMauphie
    Participant

    Thanks a lot,

    #38523

    Artem Temos
    Keymaster

    You are welcome.

Viewing 5 posts - 1 through 5 (of 5 total)