Skip to content

Commit

Permalink
Define custom excerpt length
Browse files Browse the repository at this point in the history
** Why are these changes being introduced:

* WordPress has a default limit for page excerpts of 55 words, broken on
  a word boundary. This is frequently too short of a snippet to give a
  good indication of page content.

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/pw-60

** How does this address that need:

* This defines a custom function to extend the length of the excerpt to
  9,999 words - which is longer than any page on our site should be.
  With this change, the opengraph tag `og:description` in our site
  headers should be a copy of all text in the page body.

** Document any side effects to this change:

* This makes the notion of an "excerpt" kind of meaningless, as it just
  repeats the full body copy.
  • Loading branch information
matt-bernhardt committed Sep 21, 2023
1 parent c990416 commit baedfaf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions web/app/themes/mitlib-parent/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,17 @@ function customize_body_class( $classes ) {
}
add_filter( 'body_class', 'Mitlib\Parent\customize_body_class' );

/**
* Defines a new value for the length of the excerpt.
*
* @param int $length Number of words to include in the excerpt.
* @return int The maximum number of words to include from the excerpt.
*/
function custom_excerpt_length( $length ) {
return 9999;
}
add_filter( 'excerpt_length', 'Mitlib\Parent\custom_excerpt_length', 999 );

/**
* ============================================================================
* ============================================================================
Expand Down

0 comments on commit baedfaf

Please sign in to comment.