Title: Single Listing Permalink
Last modified: November 27, 2020

---

# Single Listing Permalink

 *  Resolved [aloteri](https://wordpress.org/support/users/aloteri/)
 * (@aloteri)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/single-listing-permalink/)
 * Hi,
 * first of all, thanks for the amazing script.
 * As deafult the listing page uses the overall permalink setup, so if I use “/blog/%
   postname%/” for the blog section also the listing page will use the slug “blog”.
 * My question is, how can I not use the “blog” slug and use the directory slug 
   instead?
 * I read here on the support forum a similar request with the Post ID, but I would
   like to use the post_name function. I tried with this code, the first part works
   well, but something is wrong on the rewrite rule (second part).
 *     ```
       function acadp_post_type_link( $post_link, $post = 0 ) {
           if( $post->post_type === 'acadp_listings' ) {
       	$permalink_settings = get_option( 'acadp_permalink_settings' );
               return home_url( $permalink_settings['listing'].'/' . $post->post_name . '/' );
           } else {
               return $post_link;
           }
       }
       add_filter( 'post_type_link', 'acadp_post_type_link', 1, 3 );
   
       function acadp_rewrites_init(){
           $permalink_settings = get_option( 'acadp_permalink_settings' );
           add_rewrite_rule( $permalink_settings['listing'].'/([0-9]+?$', 'index.php?post_type=acadp_listings&p=$matches[1]', 'top' );
       }
       add_action( 'init', 'acadp_rewrites_init' );
       ```
   
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [pluginsware](https://wordpress.org/support/users/pluginsware/)
 * (@pluginsware)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/single-listing-permalink/#post-13729467)
 * Hi,
 * Kindly replace your existing code with the following,
 * function acadp_remove_blog_prefix( $args, $post_type ) {
    if ( $post_type == ‘
   acadp_listings’ ) { $args[‘rewrite’][‘with_front’] = false; }
 *  return $args;
    }
 * add_filter( ‘register_post_type_args’, ‘acadp_remove_blog_prefix’, 10, 2 );
 * Hope this solved your issue!
 * Thanks
 *  Thread Starter [aloteri](https://wordpress.org/support/users/aloteri/)
 * (@aloteri)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/single-listing-permalink/#post-13729486)
 * Super super thank you.
    It perfectly works !

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Single Listing Permalink’ is closed to new replies.

 * ![](https://ps.w.org/advanced-classifieds-and-directory-pro/assets/icon-128x128.
   png?rev=1506527)
 * [Advanced Classifieds & Directory Pro](https://wordpress.org/plugins/advanced-classifieds-and-directory-pro/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-classifieds-and-directory-pro/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-classifieds-and-directory-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-classifieds-and-directory-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-classifieds-and-directory-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-classifieds-and-directory-pro/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [aloteri](https://wordpress.org/support/users/aloteri/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/single-listing-permalink/#post-13729486)
 * Status: resolved