Site logo

Archived topic

Odd behaviour when using custom archive page

7 replies · Started by Hendrik on November 19, 2021

Viewing posts 1–8 of 8

When I use the script from here
https://generatepress.com/forums/topic/linking-author-in-post-to-about-page/

inside my functions.php, with my permalink settings to “custom structure: /%category%/%postname%/”

the slug for a post in the category “widgets” will render

“mydomain.com/widgets/blue-widgets”

That looks as intended, HOWEVER, the page that gets rendered under that slug is not the post content for “blue-widgets”, but the category page (which is using the static page as per enforced by the above script).

Basically, it looks like URL for the post always redirects to the category page.
I’m not using any SEO or redirection plugins, btw.

Would you have any ideas why this is happening? 🙁

Hi Hendrik,

The script you linked should not cause this effect.

If you disable the script does the issue still happen?

Have you tried disabling all plugins and switching to parent theme (if you are suing one) to test?

Let me know :)

Hi Ying,
Disabling the script returns the site to normal behaviour.
This, of course, doesn't solve my problem of me needing a very custom category page that doesn't just loop in a list of posts. :-(

Hi Hendrik,

You are linking us to 2 different snippets, it really confused us since the first snippet should not cause the issue.

To fix the link issue, can you try using post name option instead of the custom structure at settings > Permalink?

By the way, I found that you added the snippet directedly to the theme's functions.php file without using a child theme, I would NOT recommend doing that, the changes will be erased during updates.

Can you install a plugin called code snippetand add the snippet to that plugin instead?

Let me know :)

Hi Ying,
Changing the permalink settings to post name will make the slug work, but removes the category from the slug.

So instead of “mydomain.com/widgets/blue-widgets”, I get “mydomain.com/blue-widgets” for the post slug.

I'm trying to establish a physical silo structure, so I'd really need that slug to reflect the regular category hirarchy.

It might be best to ask that question on Stack Overflow - there might be some smart person who has the answer to that. I think it may entail rewrite rules.

This archived topic is closed to new replies.