Photo View excerpt

Home Forums Calendar Products Events Calendar PRO Photo View excerpt

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #993342
    John Paul
    Participant

    Hi.. in Photo view, I would like to change the “get excerpt” to an auto-excerpt function, so that it automatically goes and get the first 10 words and then prints “read more” . I think this is important because at the moment it would rely on my client adding the right amount of words in the event post “excerpt” and I do not want to rely on their discipline to do this, because they will not get it right 100% of the time and it will spoil the look I have created where the I have the Photo look as same height containers.

    There is some information in the forum as how to do this, but it is from a long time ago.

    So, what is the current view as to the best way to achieve this? btw..I would prefer to code it rather than use a plugin.
    BTW…having an option to do this for the event title as well would be awesome

    Many thanks

    #993615
    George
    Participant

    Hey John,

    Our excerpt function just calls the default WordPress function get_the_excerpt(), so if you filter that alone you should be able to successfully auto-filter the length of excerpts.

    Check out this Codex page for an example → https://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length

    And check out this list of Events conditional checks → https://gist.github.com/jo-snips/2415009

    Combine the knowledge from both things to write a snippet like this in your theme’s functions.php file, it should return one length in general and then a second length if it’s on the Tribe Photo View:


    function custom_excerpt_length( $length ) {
    if ( tribe_is_photo() ) {
    return 30;
    }

    return 40;
    }
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

    Play around with that and let us know if it helps!

    — George

    #993621
    John Paul
    Participant

    Hi..if I can ask ..will this take the word count from the excerpt manually pasted into the post?? or would it take it from the content written into the post..as the latter would be the best option in my view…cheers

    #993980
    George
    Participant

    This will use the excerpt manually entered in the post, although if one doesn’t exist, the normal post content should be used as a fallback.

    If you find it does not meet your needs, your best option is to apply filters to the_content instead of the excerpt or some other alternative.

    Cheers,
    George

    #994123
    John Paul
    Participant

    Hi, no banana am afraid. I event tried just using the code from WP.ORG you linked to,

    function custom_excerpt_length( $length ) {
    return 20;
    }
    add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

    and this didn’t work either…

    I have a child folder set up for photo view and in the single-event file I can see this
    <!– Event Content –>
    <?php do_action( ‘tribe_events_before_the_content’ ); ?>
    <div class=”tribe-events-list-photo-description tribe-events-content entry-summary description”>
    <?php echo tribe_events_get_the_excerpt() ?>
    </div>

    is there anything I can do in here and then it would leave the other views to the std 55 words which I am fine with..it is just photo view I need to ensure the text is cut off at a pre-described lenght

    #994614
    George
    Participant

    Hey John,

    The function there tribe_events_get_the_excerpt() does calls the WordPress default function get_the_excerpt() – I took a screenshot of this function in the codebase for proof, just so you know I’m not misleading you! Check out the screenshot here → https://cloudup.com/cAvfa1dr8uX

    So if the code you added is not taking effect, then unfortunately there could perhaps be a problem with the way you’ve added this code to your theme or something.

    We cannot troubleshoot issues like that, unfortunately, but one thing that might be worth trying is for you to lower the priority number on the function above. For example, this:

    add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

    Would become this:

    add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 5 );

    If that doesn’t help, then I’d recommend first making a backup of all custom Events Calendar views you’ve made in your theme. Then, temporarily delete these from your site and see if anything improves.

    The original code I shared above should work – I’m sorry that you’re finding that not to be the case on your site, though there is unfortunately not much we could do to rectify that from our end of things 🙁

    Please let me know if you have further thoughts on this matter or if there’s anything else I can help with.

    Cheers,
    George

    #995880
    John Paul
    Participant

    as a thought …. do you guys know of any auto post excerpt plugin that will target different post types such as custom post types al la events??

    #996205
    George
    Participant

    I don’t know of any such plugin, unfortuanately 🙁

    #1000202
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Photo View excerpt’ is closed to new replies.