I have created a custom post type, but I do not want it to have a permalink. By default, after entering the post title, it creates a permalink. I do not need them to be generated.
From my reading, it is said that custom post type will have a permalink and there is no way of disabling it. Is there a way that I can prevent the ajax call that receives the permalink?
This will remove:
If you want to remove permalink only, replace the line containing
preg_replace
withUPDATE:
get_sample_permalink_html
has changed in version 4.4.Here is the updated and tested code:
While the accepted answer seems to only hide the permalink from showing, but still being generated and accessible, you can disable the permalink from showing and being accessible by setting certain
register_post_types
parameters.I’ve achieved what I needed by only setting the following, but depending on your specific case, you may want to adjust some of the other parameters.
More: https://wordpress.stackexchange.com/a/108658/33056
As the WordPress documention suggests, simply turn off the
public
argument of the registered post type.It will have the consequence to turn off the following arguments, only if not specified otherwise:
So you will not get anymore the possibility to go on the singular and the permalink is not shown anymore on the admin and the “view” buttons are hidden too.
PS: The selected answer shows what should not be done when it comes to WordPress development, badly. There is no need to alterate the render of some HTML and/or code something since there is a WordPress builtin Post Type API for that.
So please consider my answer, as it meets all the question requirements and it is simple and straight to the point with a builtin solution.