Tagged: 

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1407638

    Hi,

    unfortunately the post is closed, because I have the same problem:
    The function from @ismael in this post

    is not working, look at the three points after each breadcrumb part instead only at the end:

    zzz

    Could you please give me an updated version of this function?

    function avia_breadcrumbs_trail_mod($trails)
    {
        $newtrails = [];
    
        foreach ($trails as $key => $trail) {
            $oldLabel = strip_tags($trail);
            $newLabel = substr($oldLabel, 0, 10).'...';
    
            $newtrails[$key] = str_replace($oldLabel, $newLabel, $trail);
        }
    
        return $newtrails;
    }
    
    add_filter('avia_breadcrumbs_trail', 'avia_breadcrumbs_trail_mod', 50, 1);

    Thank you.

    #1407913

    Hey BeeCee,

    Thank you for the inquiry.

    The filter still works properly on our end as shown in the screenshot below. Did you apply another callback for the avia_breadcrumbs_trail filter in the functions.php file?

    // https://1drv.ms/i/s!AjjTfXSRbKTvgcJoZkU_ay_8o4OYUQ?e=njiNTz

    Please check the functions.php file and check if there are other functions using the same filter.

    Best regards,
    Ismael

    #1407924

    No, I have no other snippet concerning the breadcrumbs active, please see the private content.
    I have even tried to disable all plugins and all snippets – but with no effect on this issue.
    In case if this is important: it is a multisite with sub-sites.

    I created within this network a brand new sub site with a pure Enfold, no plugins, no snippet except for the snippet here, no imported theme settings, no theme files changed – just a pure fresh new subsite with this one single post – and the breadcrumbs are also shown weird like this:

    zzz

    I assume a connection between the snippet and the fact that I have a network installation -> URLs! -> Blog URL within a multisite

    Some years ago with an old version of ENFOLD I had another problems with breadcrumbs – also with multisite, probably this helps to find a solution for this issue:

    • This reply was modified 1 year, 7 months ago by BeeCee. Reason: new login data to new sub site of network
    #1408127

    Hi,
    Thank you for your patience and the link to your site, I was not able to view your Code Snippets plugin as I got the error: Du bist leider nicht berechtigt, auf diese Seite zuzugreifen. but I was able to disable the plugin.
    Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor or add it to your Code Snippets plugin as a php snippet:

    function truncate_breadcrumb_trail_end() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
    (function($){
    var elem = $(".breadcrumb-trail .trail-end");
    if(elem){
        if (elem.text().length > 20)
                elem.text(elem.text().substr(0,20)+'...');
    }
    })(jQuery);
    });
    </script>
      <?php
    }
    add_action( 'wp_enqueue_scripts', 'truncate_breadcrumb_trail_end', 99 );

    This will truncate the breadcrumb trail-end to 20 characters:
    Enfold_Support_2129.jpeg
    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.

    Best regards,
    Mike

    #1408136

    Thanks, Mike, this code works concerning the length of the breadcrumbs.
    But I discovered a weird behaviour of your code concerning the breadcrumbs, as well as your code from today concerning the category above the title – see here –>:

    if you reload the page, you will see for a short moment
    a) the not truncated breadcrumbs before they appear truncated thanks of your code, and
    b) the category name below the post title before it then appears above the post title.

    That looks strange. Is it because of this EventListener thing?
    Is there another way to solve this so that when you refresh the page you don’t see the old version for a moment?
    Something like this –> here?

    • This reply was modified 1 year, 7 months ago by BeeCee. Reason: new login data
    #1408179

    Hi,
    Thanks for the feedback, I’ve tried checking the post a couple of times over the last hour but it keeps giving a maintain notice, but any ways, I know about a javascript delay you are refuring to and it could be due to the EventListener that I added, this typically helps prevent the script from running before jQuery, you can try removing it.
    Typically this is not an issue once caching is using on the site, I note this your site is a sandbox.

    Best regards,
    Mike

    #1408186

    sorry, maybe the maintanence mode was because I had the post open in another browser window. I have closed that now.

    I’m sorry, but I don’t like it when the versions “jump” like this when the page is reloaded: the shortened breadcrumbs and the category name above the post title.
    I’ve never had anything like this.
    Isn’t there another way to solve this?
    I don’t know if I’ll use a cache plugin – but that’s another story.
    For example, I use Ismael’s function here (https://kriesi.at/support/topic/postslider-php-how-to-switch-title-and-category/#post-1027605) and nothing “jumps” when the page loads .
    Or isn’t there another option as a function – for shortening the breadcrumbs and the category name above the post title please?

    #1408318

    Hi,
    Thank you for your patience, I modified the snippet removing the EventListener and changed it’s loading order and it seems to have corrected, please clear your browser cache and check.
    Please note that testing with iPads & iPhones can be hard to clear the cache, often you need to also clear the history to fully purge the cache, following these steps for Safari and note Step 4 where you will Clear the History.

    Best regards,
    Mike

    #1408398

    Thank you, Mike, that modified snippet works fine now for the breadcrumbs.
    Would you mind helping me out modifying your snippet concerning the catagory name above the post title please?
    This was my original, but closed post for it —>

    Please see private data below.

    #1408409

    Hi,
    Please clear your browser cache and check the catagory name above the post title now.

    Best regards,
    Mike

    #1408423

    Everything is fine, thank you very much for taking so much time for me, you can close this thread now, thank you.

    #1408438

    Hi BeeCee,

    I’m glad that Mike could help you :)
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘function for truncate breadcrumbs not working’ is closed to new replies.