Home Forums Plugin Support WP User Frontend (Free Version) Edit Link Override Question

This topic is: not resolved

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  sociallyfamous 5 years, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8976

    sociallyfamous
    Participant
    Post count: 91

    Hello all.

    I am using a custom permalink structure such as this /%region%/%postname%/

    For this to work I had to add a bit of code into the fuctions.php which I have added to the bottom of the post.

    When I put the setting to YES in the edit link override option, I get a 404 error. The normal edit link with the NO setting works fine.

    If I change the permalink structure to /%postname%/ it works fine.

    What do I need to change to still make it work with my permalink structure?

    Hope you guys can help.

    ——————————————————-

    // Custom permalink for ctp *region*
    
    add_filter('post_link', 'region_permalink', 10, 3);
    
    add_filter('post_type_link', 'region_permalink', 10, 3);
    
     
    
    function region_permalink($permalink, $post_id, $leavename) {
    
        if (strpos($permalink, '%region%') === FALSE) return $permalink;
    
         
    
            // Get post
    
            $post = get_post($post_id);
    
            if (!$post) return $permalink;
    
     
    
            // Get taxonomy terms
    
            $terms = wp_get_object_terms($post->ID, 'region');   
    
            if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
    
            else $taxonomy_slug = 'keine-region';
    
     
    
        return str_replace('%region%', $taxonomy_slug, $permalink);
    
    }   
    
    #8991

    Tareq Hasan
    Keymaster
    Post count: 2831

    Try to change the priority from 10 to 9 and see if it works.

    #8994

    sociallyfamous
    Participant
    Post count: 91

    Hello Tareq,

    I have tried the following with no luck

    add_filter('post_link', 'region_permalink', 9, 3);
    
    add_filter('post_type_link', 'region_permalink', 9, 3);

    Is that what you meant? And would you happen to have any other ideas?

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Edit Link Override Question’ is closed to new replies.