• Resolved giancarlo.braga

    (@giancarlobraga)


    Hi!

    I need help.

    Considering My permalink in configuration section is:
    /News/%post_id%/%post_name%/
    Yes..”news” is fixed….(its a kind of site migration and i need to keep those uRLs because of the SEO and google rank)…

    And i really need the “post id” in the middle of url..It works well with regular posts..but this way is very ugly..But when a created a post type..the URL output was that:

    /News/news/somepostslug..the post id just gone!!
    I tried to change permalink configs this way:
    /%post_id%/%post_name%/

    And then the URL output was that:
    /news/somepostslug

    Would be ok..in normal case..but not in mine.

    I need to personalize it…cuz the id..
    I just would like to remove /News/ from permalink section and use this as post type created in your plugin…obviously is the right way..and i need this..

    After that test, i tried to use /%post_id/ inside your plugin post type slug configurations..but no sucess at all..this way: /news/%post_id%/ and uRL output was:
    /news/%post_id%/somepostslug…Even worse.. 🙁

    I need the URL this way:
    /news/99999/postslug(using your plugin by creating “news” post type)….

    How can i do it??

    Thanks a lot

    https://ww.wp.xz.cn/plugins/custom-post-type-ui/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Definitely going to be some custom rewrite api setups from best I can tell. Our plugin doesn’t dive into that area, to be honest. We focus on what gets passed into register_post_type and register_taxonomy functions.

    Hello there,

    I had a similar issue and I had to do a rewrite. Maybe try this in your functions.php file:

    add_filter('post_type_link', 'my_rewrite', 1, 3);
    
    function my_rewrite( $link, $post = 0 ){
        if ( $post->post_type == 'news' ){
            return home_url( 'news/' . $post->ID );
        } else {
            return $link;
        }
    }
    
    add_action( 'init', 'my_rewrite_init' );
    
    function my_rewrite_init(){
        add_rewrite_rule(
            'news/([0-9]+)?$',
            'index.php?post_type=news&p=$matches[1]',
            'top' );
    }
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Personalized permalink’ is closed to new replies.