Pages' permalink rewrite array
-
Hello! I am having a heck of a time trying to get a certain page’s permalink to be the title. I have a page called “projects” which links to a template file. I added this to my primary menu in the admin menu builder. Everything was fine, until I changed my mind and decided to use a rewrite rule in functions.php. I used this code:
add_action('generate_rewrite_rules', 'my_generate_rewrite_rules'); function my_generate_rewrite_rules( $wp_rewrite ) { $new_rules = array( 'projects/?$' => 'index.php?paged=1&post_type=project&orderby=title&order=ASC', 'projects/page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]&post_type=project&orderby=title&order=ASC', 'projects/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&post_type=project', 'projects/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&post_type=project' ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; }
I also added a custom menu item with an href of “/projects”. Well, that didn’t give me what I wanted either, so I decided to use the project.php template/page approach again. Basically reverted back to before, using a page and using the menu builder. But now, the permalink for the page is “projects-1”.
I’ve tried flushing the rewrite rules by adding
add_action( 'generate_rewrite_rules','deactivate'); function deactivate() { global $wp_rewrite; $wp_rewrite->flush_rules(); }
to functions.php, I’ve tried changing settings>permalinks to “reset” the permalinks, and I’ve tried deleting the page and reassembling it. Now it’s “projects-2”! Obviously trashed pages’ permalink information is continuing to exist somewhere in the database, but I’m hesitant to go in there and just start dropping values. I obviously want the project page’s permalink to be /project.
Any ideas?
- The topic ‘Pages' permalink rewrite array’ is closed to new replies.