manoj
manoj

Reputation: 297

All links Display home page after "changing permalinks to other than default" in wordpress

My website link https://myanatomy.in

I don't know what happened suddenly. All the links in website is showing home page content.

I didn't do migration or Add plugin or anything I was just working on wordpress posts.

Now pages will showing its content only if I choose default settings in permalinks. If I change to other settings All the links in website will show home page content.

I tried with

  1. Deleting .htaccess file and saving permalinks settings again and again but "No Use".

I think there is no problem with the .htaccess overriding, because it was working before

Upvotes: 0

Views: 81

Answers (1)

manoj
manoj

Reputation: 297

I figure out that some code in theme function.php was stopping my rewrite_rules

I removed this code which was there in my function.php inside theme folder

add_filter('rewrite_rules_array', 'my_rewrite_rules');
     add_action('init', function(){
    add_rewrite_rule( 
       '^company/([^/]+)([/]?)(.*)', 
       //!IMPORTANT! THIS MUST BE IN SINGLE QUOTES!:
       'index.php?company=yourPageSlug&name=$matches[1]', 
       'top'
    );   
 });

 add_filter('query_vars', function( $vars ){
    $vars[] = 'company'; 
    $vars[] = 'name'; 
    return $vars;
});

Upvotes: 1

Related Questions