Rewrite on custom post type permalink not working?
rewrite accepts a boolean or array, try: ‘rewrite’ => array( ‘slug’ => ‘projects’ ) make sure to visit your permalinks settings page to flush rewrites after you make the change.
rewrite accepts a boolean or array, try: ‘rewrite’ => array( ‘slug’ => ‘projects’ ) make sure to visit your permalinks settings page to flush rewrites after you make the change.
Good plugin: http://urbangiraffe.com/plugins/redirection/ You can import CSV files of URLs to redirect, so use the string site:mydomain.com in Google to grab all your indexed URLs, get them into a file and when the WP site is live, import the file and then select the new target WP pages. The plugin has good 404 logging, too.
I have finally solved my rewrite rule problem. I used the class outlined in the answer of this wordpress.stackoverflow question. After including that class I used the following code to make it work: // These query vars can be retrieved on the page by using get_query_var( ‘queryvar1’ ); $options = array( ‘query_vars’ => array( ‘queryvar1’, … Read more
WP redirects pretty permalink to query string
Well, I found the solution. It seems that, when applying a rewrite rule on a custom post type post, one needs to tell WP the custom post type’s name within the rewrite rule itself. Here’s the code that does NOT work (redirects and drops parameter variables instead of rewrite): function add_rewrite_rules($rules) { $newrules = array(‘cpt-slug/([^/]+)/([^/]+)/?$’ … Read more
You can do this without adding rewrite rules by changing the $date_structure of the $wp_rewrite instance of the WP_Rewrite class: function wpa116030_init(){ global $wp_rewrite; $wp_rewrite->date_structure=”about/blog/archive/%year%/%monthnum%/%day%”; } add_action( ‘init’, ‘wpa116030_init’ ); Visit your Permalinks settings page after adding this code to flush the rewrite rules.
Nilambar’s comment solved this for me. “You can pass two values as comma separated in a single parameter events. And later parse value correctly in your page. – Nilambar” I use this to get posts with tag1 OR tag2: echo ‘<a href=”‘.esc_attr(add_query_arg( ‘events’, ‘tag1,tag2′)).'”>Linkname</a>’; And to get all posts with tag1 AND tag2 simply use … Read more
You can use the post_link_category filter to remove child categories from permalinks: function wpse147453_remove_child_categories_from_permalinks( $category ) { while ( $category->parent ) { $category = get_term( $category->parent, ‘category’ ); } return $category; } add_filter( ‘post_link_category’, ‘wpse147453_remove_child_categories_from_permalinks’ );
Mark Jaquith uses “+” as the search query string delimiter in his Nice Search Plugin. Here’s what he does: function cws_nice_search_redirect() { if ( is_search() && strpos( $_SERVER[‘REQUEST_URI’], ‘/wp-admin/’ ) === false && strpos( $_SERVER[‘REQUEST_URI’], ‘/search/’ ) === false ) { wp_redirect( home_url( ‘/search/’ . str_replace( array( ‘ ‘, ‘%20’ ), array( ‘+’, ‘+’ ), … Read more
how to use two permalinks for one custom post type