Correct permalinks and 404-error

admin2025-01-07  4

I have a paid plugin that creates a custom type categories and posts in this categories. I want to get URLs like site_name/category_name/post_name. This plugin forms links like this:

  • List item

for categories - site_name/category_name

  • List item for posts - site_name/category_name

I have installed plugin Custom Post Type Permalinks, configured it. When I click on post link, I have a 404 page of theme (not server). But URL is right. In the post edit page the permalink is right too. Pages shows correctly.
I can't change any file of paid plugin or theme (it's already child theme). Can I resolve my problem with .htaccess or m.b. some another way? P.S. By the way, I've already tried to configure permalinks in Settings->Permalinks->Custom structure but result is the same.

I have a paid plugin that creates a custom type categories and posts in this categories. I want to get URLs like site_name/category_name/post_name. This plugin forms links like this:

  • List item

for categories - site_name/category_name

  • List item for posts - site_name/category_name

I have installed plugin Custom Post Type Permalinks, configured it. When I click on post link, I have a 404 page of theme (not server). But URL is right. In the post edit page the permalink is right too. Pages shows correctly.
I can't change any file of paid plugin or theme (it's already child theme). Can I resolve my problem with .htaccess or m.b. some another way? P.S. By the way, I've already tried to configure permalinks in Settings->Permalinks->Custom structure but result is the same.

Share Improve this question asked Jan 25, 2016 at 9:32 VlodkoVlodko 1931 silver badge13 bronze badges 1
  • You have, in all probabilty, some kind of conflict between your plugins. Thinks get really messy if you have a couple of plugins that tries to do the same thing. I'm almost sure that simply changing rewrite rules in .htaccess will not solve the issue, you will need to resolve the conflict between the plugins – Pieter Goosen Commented Jan 25, 2016 at 9:49
Add a comment  | 

2 Answers 2

Reset to default 0

This is a common problem (that I just finished fixing). It seems to arise in a few different ways. Some people seem to be able to fix it by selecting the default permalink format and then switching back to their preferred one.

In my case, the problem seemed to be that I didn't have mod-rewrite properly enabled. Once I did the steps in this post, the problem was resovled.

I think I may have also made [this change], (Category links suddenly started giving 404 errors), but I'm pretty sure it was fully enabling mod-rewrite that did the trick.

Permalinks require mod_rewrite on webserver and should work after you click Save button on Settings > Permalinks screen from WP admin dashboard.

Due to various plugins or updates, the permalinks structure can sometimes get broken and 404 pages are shown on previously working URLs. You can Save permalinks again from backend.

There's also an automated fix by adding this code to index.php :

            if (is_404())   
        {
        global $wp_query;
        $page_slug = $wp_query->query_vars['name'];
        if ($page_slug) 
            { 
            $page = get_page_by_path($page_slug);
            if ($page) $wp_rewrite->flush_rules(true);
            }
        }   

This flushes the rules if it detects that 404 error occurs on a page that exists.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736260329a658.html

最新回复(0)