rewrite - Wordpress - changing a custom post type archive link -


i had create custom post type, let's call 'trucks'. link archive of posts looks that: http://example.com/wpdirectory/?post_type=trucks want that: http://example.com/wpdirectory/trucks without '?post_type=' query. how can affect it?

try using add_rewrite_rule() function functions.php file. try this:

add_action( 'init', 'rewriteposttype' ); function rewriteposttype(){     add_rewrite_rule('^wpdirectory/([^/]*)/?','index.php?post_type=$matches[1]','top');     add_rewrite_tag('%post_type%','([^&]+)'); } 

otherwise can overwrite permastructures in settings -> permalinks in wordpress , hard code in.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -