Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpa_alter_cat_links( $termlink, $term, $taxonomy ){
- if( 'category' != $taxonomy ) return $termlink;
- return str_replace( '/category', '', $termlink );
- }
- add_filter( 'term_link', 'wpa_alter_cat_links', 10, 3 );
- function wpa_alter_cat_links( $termlink, $term, $taxonomy ){
- if( 'category' == $taxonomy && 0 == $term->parent ){
- return str_replace( '/category', '', $termlink );
- }
- return $termlink;
- }
- add_filter( 'term_link', 'wpa_alter_cat_links', 10, 3 );
- RedirectMatch 301 ^/category/(.*)$ /$1
- function loadPageFirst() {
- // get the actual category
- $actualCategory = get_category (get_query_var('cat'));
- // get the page with the same slug
- $matchingPage = get_page_by_path($actualCategory->slug);
- // If no match, load the normal listing template and exit (edit if you are using a custom listing template, eg. category.php)
- if (!$matchingPage) {
- include( get_template_directory() . '/archive.php');
- die();
- }
- // Make a new query with the page's ID and load the page template
- query_posts('page_id='.$matchingPage->ID);
- include( get_template_directory() . '/page.php');
- }
- add_filter( 'category_template', 'loadPageFirst' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement