Viewing 15 replies - 1 through 15 (of 22 total)
  • Hello Chouby,

    I have this problem with custom posts.
    I too have /%postname%/ permalinks.
    I’m getting 404 errors on all custom post type pages.

    For example, I have a custom post type called ‘wallpapers’, with a post called ‘time-machine’, but /wallpapers/time-machine/ throws a 404 error.

    WordPress itself does have a similar problem, but none of those solutions worked for me..

    Plugin Author Chouby

    (@chouby)

    Did you flush your rewrite rules ? (Settings-> permalinks : click on save changes).

    The normal url for an English post would be: /en/wallpapers/time-machine/ (except if English is the default language and you chose to hide the language code for it ?)

    Yes I’ve tried re-saving it a few times.

    However I do hide the language code – i give different names to all my posts and pages in different languages. This might not be a good idea but it seemed to work out fine up to this point..

    Thank you,
    Dabiel

    Plugin Author Chouby

    (@chouby)

    I wrote something wrong about the url. The language code is added only if the option “Add language information to all URL including posts, pages, categories and post tags” is checked.

    Yes, this is a limitation of the way Polylang works. You must have different names (or more exactly different slugs) for all posts and pages in different languages.

    Do you register the post type yourself or do you use a plugin ?

    I am keeping all my slugs different. I’d like to avoid adding language information to the url.

    I’ve registered my post types manually. Here’s my code:

    register_post_type('wallpapers', array(
        'label' => __('Wallpapers'),
        'singular_label' => __('Wallpaper'),
        'public' => true,
    	'_builtin' => false,
        'show_ui' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'query_var' => false,
        'supports' => array('title', 'editor', 'trackbacks', 'custom-fields', 'thumbnail', 'comments'),
        'rewrite' => array('slug' => 'wallpapers')
    	));
    Plugin Author Chouby

    (@chouby)

    I copied pasted the above code in a function hooked to the init action. I don’t get a 404 error but another bug (the language of the theme is always set to default whatever the language of the custom post type). The problem is linked to the line:

    'query_var' => false,

    which breaks the Polylang rewrite rules. Is there a specific reason for you not to set it to true ? Could you tell me if setting it to true (and then refresh your rewrite rules) solves your problem ?

    On my side, I will have to further look at this parameter and examine its consequences on rewrite rules.

    You are my hero. I don’t know why I included the query_var, I guess I just copied it over from some sample code, while trying make things work..

    Anyway, I’ve simplified my function and now it works like a charm:

    register_post_type('wallpapers', array(
        'label' => __('Wallpapers'),
        'singular_label' => __('Wallpaper'),
        'public' => true,
    	'_builtin' => false,
        'supports' => array('title', 'editor', 'trackbacks', 'custom-fields', 'thumbnail', 'comments')
    	));

    I think I owe you a beer or two.

    Plugin Author Chouby

    (@chouby)

    Great. On my side, I found the reason for the bug. I will correct it with the next release.

    Hi all,

    This is a problem that I’m still encountering.

    The site I work on has a number of different parent > child categories across two languages. The URL structure I’m using is the ‘postname’ option. When categories are either edited or added the whole site gets 404s. At the moment I have to go to the permalinks setting screen and manually flush the rewrites rules. This isn’t too bad when it comes to myself doing it, but for the other users is more complicated.

    Is there an elegant solution out there to this problem?

    I’m using Polylang v 0.9.2

    Plugin Author Chouby

    (@chouby)

    Never got such problem. Did you test for a plugin or theme conflict? Does the problem occur only with %postname% permalink structure?

    Yes, it does only seem to occur when the permalinks are on. As for conflicts, this I’m unsure of, although I do know that the theme I’m developing on is available for translation.

    Plugin Author Chouby

    (@chouby)

    You should test first with WP + Polylang + Twenty Ten and then swithc your theme and add other plugins one by one to detect if there is a conflict.

    If that may help, I got a similar problem some weeks back.

    I created a fresh .htaccess file (from this page of the Codex) and saved my permalinks again. It solved my issues.

    Don’t forget to backup your .htaccess before ??

    Sorry for start a new chat… I have the same problem, all the entries, pages… goes to 404.

    Plugin Author Chouby

    (@chouby)

    Did you try what has been suggested above?

    • Resave your permalinks first.
    • make test with WP + Polylang + Twenty Ten and then switch your theme and add other plugins one by one to detect if there is a conflict
Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘[Plugin: Polylang] 404 errors with /%postname%/ permalinks’ is closed to new replies.