Home › Forums › Calendar Products › Events Calendar PRO › Photo View excerpt
- This topic has 8 replies, 3 voices, and was last updated 10 years, 7 months ago by
Support Droid.
-
AuthorPosts
-
August 5, 2015 at 4:54 am #993342
John Paul
ParticipantHi.. 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 awesomeMany thanks
August 5, 2015 at 2:42 pm #993615George
ParticipantHey 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
August 5, 2015 at 2:58 pm #993621John Paul
ParticipantHi..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
August 6, 2015 at 10:49 am #993980George
ParticipantThis 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,
GeorgeAugust 7, 2015 at 1:09 am #994123John Paul
ParticipantHi, 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
August 9, 2015 at 5:17 pm #994614George
ParticipantHey 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,
GeorgeAugust 13, 2015 at 1:25 pm #995880John Paul
Participantas 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??
August 14, 2015 at 4:03 pm #996205George
ParticipantI don’t know of any such plugin, unfortuanately 🙁
August 29, 2015 at 7:05 am #1000202Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Photo View excerpt’ is closed to new replies.
