0

I can't figure out how to remove the word "date from the permalink for yearly archives. For example:

[http://localhost/wordpress/news/date/2012]

On single news pages the permalink looks like this:

[http://localhost/wordpress/news/2012/news-article/]

I've created a custom post type called "News". The slug for this post_type is obviously "news". I've set 'archive' to true and 'with_front' to false.

I want a clean News Archive which can be broken down by years. I tried a different solution, but it posed problems. I set the 'archive' to false and created a News page with a custom template, for current News Articles. I then created child pages for each year's News Articles, but Wordpress added -2 to the permalink.. For example:

2012 = news/2012-2

I just want my permalinks to be like this:

news

news/2012

news/2012/news-item

I've tried a few plugins but nothing seems to work. Any Ideas?

  • Do you have the %post_id% in your permalink structure somewhere? – Otto Jul 18 '13 at 20:51
0

go to Settings -> Permalinks tab

Try this:

/%category%/%year%/%postname%/
  • I tried that. I figured it out. – Nick Jul 19 '13 at 11:39
0

WordPress Answers showed me a related question that helped.

custom post types, wp_get_archives and add_rewrite_rule

I had to modify the code:

add_action('init', 'wpse50530_journal_archive_rewrite');
function wpse50530_journal_archive_rewrite(){
    add_rewrite_rule('^news/([0-9]{4})/?','index.php?post_type=news&year=$matches[1]','top');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.