Add Post and Comments menu no longer visible

Here is my solution without changing the post object:

Add a new rewrite rule, look this up if you need to:

add_rewrite_rule("^news/?$", "index.php?post_type=post&category_name=news", "top");

Adding category_name=news triggers the archive.php file to be used. Yes, you need to add the category news to every post but this is no big deal if you set news to the default category in writing settings.

Change post archive link:

function my_post_archive_link( $link, $post_type ) {
    if ( $post_type == 'post' ) {
        $link = site_url( '/news/' );
    }

    return $link;
}
add_filter( 'post_type_archive_link', 'my_post_archive_link', 10, 2 );

This is the best solution I have come up with- without having to hack the post object or create a new custom post type just for news.

Leave a Comment