Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. add_permastruct(
  2. 'pg_review',
  3. "/reading/%year%/%monthnum%/%day%/%reading%/",
  4. array( 'with_front' => false )
  5. );
  6.  
  7. add_rewrite_rule(
  8. '^reading/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$',
  9. 'index.php?post_type=pg_review&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
  10. 'top'
  11. );
  12. add_rewrite_rule(
  13. '^reading/([0-9]{4})/([0-9]{1,2})/?$',
  14. 'index.php?post_type=pg_review&year=$matches[1]&monthnum=$matches[2]',
  15. 'top'
  16. );
  17. add_rewrite_rule(
  18. '^reading/([0-9]{4})/?$',
  19. 'index.php?post_type=pg_review&year=$matches[1]',
  20. 'top'
  21. );
  22.  
  23. function wpd_pg_review_permalinks( $url, $post ) {
  24. if ( 'pg_review' == get_post_type( $post ) ) {
  25. $url = str_replace( "%year%", get_the_date('Y'), $url );
  26. $url = str_replace( "%monthnum%", get_the_date('m'), $url );
  27. $url = str_replace( "%day%", get_the_date('d'), $url );
  28. }
  29. return $url;
  30. }
  31. add_filter( 'post_type_link', 'wpd_pg_review_permalinks', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement