1
votes

I purchased a wordpress theme, which came with custom plugin, that allows custom posts, which is titled 'tour'.

The permalink to view the custom post currently is site.com/tour/post-name

I am trying to change the /tour/ so I have updated all the code in the files of the plugin folder from 'tour' to 'visa'.

I also went to my database and changed all my posts from wp_posts and updated the post_type from tour to visa.

Now the custom posts show in my posts section as it should, but when i go to mysite.com/visa/post-name it goes to my 404 page.

Am i missing something? do i need to change anything else?

thanks

2

2 Answers

0
votes

Check your .htaccess files, in the plugin and in your site root. The theme may have rewrite rules that need to be changed.

0
votes

If the plugin has a built in post type using rewrite in the arguments, I wouldn't recommend overwriting it in the plugin files because if they push out an update to it, it will overwrite your changes.

Your best bet is to overwrite the post type arguments with the register_post_type_args filter. Note you may need to adjust the priority from 10, but this should get you started:

add_filter( 'register_post_type_args', 'scotty_tour_to_visa', 10, 2 );
function scotty_tour_to_visa( $args, $post_type ){
    if( $post_type == 'tour' ){
        $args['rewrite']['slug'] = 'visa';
    }

    return $args;
}

Also note that I'd recommend rolling back the changes you made, and using the above filter, or add_rewrite_rule(), as what you've done isn't future-proof if there's a security update that comes out for the theme/plugin - and you'll have to redo all/most of what you've done.