Guest User

Untitled

a guest
May 20th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. /* == added by msolution == */
  2. function replace_catid_prev( $join , $in_same_cat, $excluded_categories)
  3. {
  4. // edit this accordingly to get previous post from this cat id.//
  5. // to add multiple cat ids add them seperating them with a comma ',' = '74, 75, 76'; //
  6. $cat_id = '74';
  7.  
  8. if( ! empty( $join ) && $in_same_cat )
  9. return preg_replace('#tt.term_id IN \((.*?)\)#ism', 'tt.term_id IN ('.$cat_id.')', $join);
  10. else
  11. return;
  12. }
  13.  
  14. function replace_catid_next( $join , $in_same_cat, $excluded_categories)
  15. {
  16. // edit this accordingly to get next post from this cat id.//
  17. $cat_id = '74';
  18.  
  19. if( ! empty( $join ) && $in_same_cat )
  20. return preg_replace('#tt.term_id IN \((.*?)\)#ism', 'tt.term_id IN ('.$cat_id.')', $join);
  21. else
  22. return;
  23. }
  24.  
  25. add_filter('get_previous_post_join', 'replace_catid_prev', 10, 3 );
  26. add_filter('get_next_post_join', 'replace_catid_next', 10, 3);
  27.  
  28. /* == /added by msolution == */
Add Comment
Please, Sign In to add comment