• Resolved patriqueuiliam

    (@patriqueuiliam)


    Is there a way to change the url of the events and put random urls?

    Many events are created with the same name and this becomes a problem to solve. For example:

    /event-name1
    /event-name2
    /event-name3

    I know that in terms of SEO it might not be the best option, but in my case, the best would be like this:

    /dad23dfsda
    /4123added
    /ccawdf5das

    random urls. Can you help me to do this?

Viewing 1 replies (of 1 total)
  • Thread Starter patriqueuiliam

    (@patriqueuiliam)

    I managed to solve

    function change_events_slug( $slug, $post_ID, $post_status, $post_type ) {

    if ( 'event' === $post_type ) {

    $slug = substr( md5( rand() ), 0, 7 ); }

    return $slug;

    }

    add_filter( 'wp_unique_post_slug', 'change_events_slug', 10, 4 );

Viewing 1 replies (of 1 total)
  • The topic ‘How to generate random slugs’ is closed to new replies.