Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <?php
  2. /**
  3. * Remover URL Custom Type
  4. */
  5. function na_remove_slug( $post_link, $post, $leavename ) {
  6.  
  7. if ( 'editorial' != $post->post_type || 'publish' != $post->post_status ) {
  8. return $post_link;
  9. }
  10.  
  11. $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
  12.  
  13. return $post_link;
  14. }
  15. add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );
  16.  
  17. function na_parse_request( $query ) {
  18.  
  19. if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
  20. return;
  21. }
  22.  
  23. if ( ! empty( $query->query['name'] ) ) {
  24. $query->set( 'post_type', array( 'post', 'editorial', 'page' ) );
  25. }
  26. }
  27. add_action( 'pre_get_posts', 'na_parse_request' );
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement