Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  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' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement