SHARE
TWEET

Untitled

a guest Aug 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function na_remove_slug( $post_link, $post, $leavename ) {
  2.     if ( 'houses' != $post->post_type || 'publish' != $post->post_status ) {
  3.         return $post_link;
  4.     }
  5.     $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
  6.     return $post_link;
  7. }
  8. add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );
  9.  
  10. function na_parse_request( $query ) {
  11.     if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
  12.         return;
  13.     }
  14.     if ( ! empty( $query->query['name'] ) ) {
  15.         $query->set( 'post_type', array( 'post', 'houses', 'page' ) );
  16.     }
  17. }
  18. add_action( 'pre_get_posts', 'na_parse_request' );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top