Advertisement
Apina

EE4 filter event title with meta field

Nov 12th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. //this can go in the themes functions.php
  2. // or into a site specific/custom functions plugin.
  3.  
  4. function modified_ee_title($title, $sep) {
  5. global $post;
  6. $postype = get_post_type( $post );
  7. //if not an EE event, return
  8. if($postype != "espresso_events" || !in_the_loop() ) { return $title; }
  9.  
  10. //get the custom/meta fields
  11. $meta = get_post_custom($post->id);
  12.  
  13. //if the meta field called abc doesnt exist, return
  14. //obviously change abc to the actual meta key...
  15. if( !isset($meta['abc']) ) { return $title; }
  16.  
  17. //modify the title
  18. $title = $title . ' ' . $meta['abc'][0];
  19.  
  20. //return the modified title
  21. return $title;
  22.  
  23. }
  24. add_filter( 'the_title', 'modified_ee_title', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement