P粉4768839862023-08-10 10:28:03
register_post_type()
The rewrite
parameter of the function has a with_front
parameter. When set to false
, it will not be used in the fixed link Add a prefix to the structure.
register_post_type( 'cpt', array( 'rewrite' => array( 'with_front' => false, ) );
The above code will prevent /blog/
from appearing in CPT's post URL, but I don't know if that means the URL will work in the root directory.