• Resolved evocharanjit

    (@evocharanjit)


    I want to show the address in url bar like localhost/listingname or listingname.localhost.com. But it is showing localhost/directory/listingname. I want to remove /directory/ within the url.
    Please help me to change the url bar address permalink.

    • This topic was modified 7 years, 2 months ago by evocharanjit.
    • This topic was modified 7 years, 2 months ago by evocharanjit.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,
    First of all, please make sure that “Listing Slug” field is empty which can be found going Directory Settings >> Listing Settings >> Single Listing and then copy the following code and paste it to your theme’s functions.php file.

    function atpdp_remove_slug( $post_link, $post ) {
    
    if ( 'at_biz_dir' != $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', 'atpdp_remove_slug', 10, 2 );
    
    function atpdp_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', 'at_biz_dir', 'page' ) );
    }
    }
    add_action( 'pre_get_posts', 'atpdp_parse_request' );
    Thread Starter evocharanjit

    (@evocharanjit)

    Thanks,
    it is working.
    I need some other help. How can I get the url of image on single listing page. I want to show this image in the header of the theme.

    Thread Starter evocharanjit

    (@evocharanjit)

    How I can get the url of the current listing image only in the header.

    • This reply was modified 7 years, 2 months ago by evocharanjit.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to change permalink’ is closed to new replies.