Advertisement
Guest User

ACF Gallery and Relevanssi Filter...

a guest
Jun 4th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1.  
  2. I tried this in functions.php first:
  3.  
  4. add_filter('relevanssi_excerpt_content', 'custom_fields_to_excerpts', 10, 3);
  5. function custom_fields_to_excerpts($content, $post, $query) {
  6. $images = get_post_meta($post->ID, 'gallery', true);
  7. if( $images ) {
  8. foreach( $images as $image ) {
  9. $content .= " " . $image['title'];
  10. $content .= " " . $image['caption'];
  11. }
  12. return $content;
  13. }
  14. }
  15.  
  16.  
  17. Then, I tried this version (unfortunately, neither worked):
  18.  
  19. add_filter('relevanssi_excerpt_content', 'custom_fields_to_excerpts', 10, 3);
  20. function custom_fields_to_excerpts($content, $post, $query) {
  21. $images = get_field('gallery', $post->ID);
  22. if($images){
  23. foreach( $images as $image ) {
  24. $content .= " " . $image['title'];
  25. $content .= " " . $image['caption'];
  26. }
  27. }
  28. return $content;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement