Title: Permalink Without /Listings/
Last modified: August 7, 2019

---

# Permalink Without /Listings/

 *  [smg669](https://wordpress.org/support/users/smg669/)
 * (@smg669)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/permalink-without-listings/)
 * Is there a way to set up a single listing so that the permalink does not have
   the “/listings/” in it?
 * Instead of [http://www.acmerealestate/listings/123MapleStreet](http://www.acmerealestate/listings/123MapleStreet)
   
   I would want [http://www.acmerealestate/123MapleStreet](http://www.acmerealestate/123MapleStreet)
 * It doesn’t necessarily have to display that URL in the address bar. It can be
   a redirect to the first permalink.

Viewing 1 replies (of 1 total)

 *  [mdsupport2019](https://wordpress.org/support/users/mdsupport2019/)
 * (@mdsupport2019)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/permalink-without-listings/#post-11884932)
 * You can add the following code to your theme’s functions.php file, but you just
   have to keep in mind that conflicts can happen easily…
 * First, we will remove the slug from the permalink:
 *     ```
       function na_remove_slug( $post_link, $post, $leavename ) {
   
           if ( 'listings' != $post->post_type || 'publish' != $post->post_status ) {
               return $post_link;
           }
   
           $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
   
           return $post_link;
       }
       add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );
       ```
   
 * Just removing the slug isn’t enough. Right now, you’ll get a 404 page because
   WordPress only expects posts and pages to behave this way. You’ll also need to
   add the following:
 *     ```
       function na_parse_request( $query ) {
   
           if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
               return;
           }
   
           if ( ! empty( $query->query['name'] ) ) {
               $query->set( 'post_type', array( 'post', 'listings', 'page' ) );
           }
       }
       add_action( 'pre_get_posts', 'na_parse_request' );
       ```
   
 * You will need to refresh your permalinks by going to Settings -> Permalinks and
   clicking the save button.

Viewing 1 replies (of 1 total)

The topic ‘Permalink Without /Listings/’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-listings_978e8f.svg)
 * [IMPress Listings](https://wordpress.org/plugins/wp-listings/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-listings/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-listings/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-listings/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-listings/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-listings/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [mdsupport2019](https://wordpress.org/support/users/mdsupport2019/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/permalink-without-listings/#post-11884932)
 * Status: not resolved