- This topic has 30 replies, 3 voices, and was last updated 4 years, 1 month ago by Tom.
-
AuthorPosts
-
March 13, 2020 at 5:45 am #1193688DavidStaffCustomer Support
Not sure – i have asked Tom to take a look at the issue.
March 13, 2020 at 5:54 am #1193696PatrykThat’s good because i think that there will be more people interested in.
March 13, 2020 at 9:40 am #1194043TomLead DeveloperLead DeveloperStrange, haven’t seen people have this issue with the code before. There’s likely something up with your rewrite rules.
You might be able to prevent it with this:
add_filter('request', function( array $query_vars ) { if ( is_admin() ) { return $query_vars; } if ( isset( $query_vars['category_name'] ) && is_archive() ) { $pagename = $query_vars['category_name']; $query_vars = array( 'pagename' => "$pagename" ); } return $query_vars; } );
March 13, 2020 at 10:18 am #1194072PatrykIt works! Thank you so much.
March 13, 2020 at 11:21 am #1194099PatrykOh no. Just realize that im wrong. Now it use the categorie archives instead of static pages…
Any other idea?
March 13, 2020 at 6:53 pm #1194291TomLead DeveloperLead DeveloperMust be something weird going on with your setup. What do you have set for permalinks in “Settings > Permalinks”?
March 14, 2020 at 2:01 am #1194412PatrykHi,
my permalink setup:
/%category%/%postname%/And my menu setup:
individual link as main menu item and category as sub menu item.Thanks.
March 14, 2020 at 8:10 am #1194787TomLead DeveloperLead DeveloperWhat if you just use the standard
%postname%
permalinks? Any difference?March 14, 2020 at 11:35 am #1194932PatrykHi Tom, that‘s it!
Any ideas to get it with the other permalink structure? Thanks again.March 14, 2020 at 4:33 pm #1195048TomLead DeveloperLead DeveloperHmm, we could try debugging in the code.
For example:
add_filter('request', function( array $query_vars ) { if ( is_admin() ) { return $query_vars; } var_dump($query_vars['category_name']); return $query_vars; } );
What does that output above the header when viewing category pages?
March 15, 2020 at 12:42 am #1195194PatrykHi Tom,
i switch permalinks to /%category%/%postname%/
The output for the category page is the same as in the post:
– string(6) “rezept“ in the category Rezept
– string(8) “hausarzt“ in the category HausarztMarch 15, 2020 at 8:12 am #1195587TomLead DeveloperLead DeveloperCan we try this now?:
add_filter('request', function( array $query_vars ) { if ( is_admin() ) { return $query_vars; } if ( isset( $query_vars['category_name'] ) && is_archive() ) { $pagename = $query_vars['category_name']; var_dump($pagename); //$query_vars = array( 'pagename' => "$pagename" ); } return $query_vars; } );
Does it output anything?
March 15, 2020 at 10:10 am #1195658PatrykHi Tom,
no nothing.
March 15, 2020 at 7:06 pm #1195907TomLead DeveloperLead DeveloperI’m assuming the action runs too early for
is_archive()
to work, that’s a shame.I’m not really sure what to do here, unfortunately.
My last guess would be to do this, but it’s just a guess:
add_filter('request', function( array $query_vars ) { if ( is_admin() ) { return $query_vars; } if ( isset( $query_vars['category_name'] ) && ! isset( $query_vars['p'] ) ) { $pagename = $query_vars['category_name']; $query_vars = array( 'pagename' => "$pagename" ); } return $query_vars; } );
category_name
should only be set when viewing a category, but I guess having it in your permalinks makes it so it’s always true.March 15, 2020 at 11:49 pm #1195983PatrykOk it does not work. But no problem. I switch back to the other permalink and than its fine for me. But thank you very much for your assistance.
-
AuthorPosts
- You must be logged in to reply to this topic.