• Resolved rex

    (@webburada)


    Hello,

    I want to remove this permalink, (event). I can change it but not completely delete it.

    NOW: example.com/event/earth-day/

    THAN: example.com/earth-day/

    • This topic was modified 1 year, 7 months ago by rex.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Rita Kikani

    (@kikanirita)

    Hi @webburada ,

    As per the wordpress default behavior, we can not change it from our plugin side, but you can achieve this functionality by changing the wordpress default behavior using the below code.

    You need to add below filter in functions.php to remove the slug from the permalink:

    function wpem_remove_slug_event_listing_slug( $post_link, $post, $leavename ) {
        if ( 'event_listing' != $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', 'wpem_remove_slug_event_listing_slug', 10, 3 );

    After adding this, you’ll get a 404 page because WordPress only expects posts and pages to behave this way. So, you’ll also need to add below action in our functions.php file :

    function wpem_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', 'event_listing', 'page' ) );
        }
    }
    add_action( 'pre_get_posts', 'wpem_parse_request' );

    Now, you have to refresh your permalinks from our wordpress backend Settings tab, then you can verify in your single event page by removing “event” from url, page will work fine.

    Thank you.

    Thread Starter rex

    (@webburada)

    Thanks. I did what you said but it didn’t work. What could be the problem?

    Plugin Author Rita Kikani

    (@kikanirita)

    Hi @webburada ,

    Sorry for the inconvenience, You need to take our upcoming version from our git repository : https://github.com/wpeventmanager/wp-event-manager/tree/3_1_37, then you need to add one more filter in your theme functions.php file to remove “/event” from current event permalink.

    function wpem_display_event_permalink( $link, $post ) {
    	$link = str_replace( '/event/', '/', $link );
        return $link;
    }
    add_filter( 'display_event_permalink', 'wpem_display_event_permalink', 10, 2 );

    I hope this will help you to resolve your issue.

    Thank you.

    • This reply was modified 1 year, 7 months ago by Rita Kikani.
    Plugin Author Rita Kikani

    (@kikanirita)

    Hi @webburada ,

    If still not work the code then please change the priority to lower and verify, sometimes other third party plugin also conflict for this filters and hook so.

    Thank you.

    Thread Starter rex

    (@webburada)

    Thanks. The link has been fixed. but other plugins still use the long link. can i fix this? (Yoast Seo-Rank Math Seo)

    ?mage:

    https://hizliresim.com/july194

    • This reply was modified 1 year, 7 months ago by rex.
    Plugin Author Rita Kikani

    (@kikanirita)

    Hi @webburada ,

    For that you need to contact that plugin only.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How can i remove Permalink’ is closed to new replies.