Skip to content

Instantly share code, notes, and snippets.

@svenl77
Created August 9, 2023 14:23
Show Gist options
  • Save svenl77/bcf3f659ade9044573879f748e5f1c6b to your computer and use it in GitHub Desktop.
Save svenl77/bcf3f659ade9044573879f748e5f1c6b to your computer and use it in GitHub Desktop.
<?php
function my_buddyforms_excerpt_length($length){
global $post, $buddyforms;
if( !isset($post->ID) ){
return $length;
}
// Filter for a specific form
$form_slug = get_post_meta($post->ID,'_bf_form_slug', true);
if( isset($form_slug ) && $form_slug == 'post'){
return 100;
}
// Filter for a specific post type.
if( $post->post_type == 'post'){
return 50;
}
return $length;
}
add_filter('excerpt_length', 'my_buddyforms_excerpt_length');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment