Anspress Categories broken [4.1]
After updating to version 4.1 , when I click one of the categories in the sidebar widget, it takes me to a page where it has the description of category and nothing else. The expected behavior was to sort out the questions by that certain category.
What is the issue?
Hello,
I was dealing with the same issue. Opening ../categories/<category> would only show an empty page.
My workaround:
In /wp-content/plugins/anspress-question-answer/addons/free/category.php, replace:
$category_id = sanitize_text_field( get_query_var( 'q_cat' ) );
with:
$request_uri_path = explode( '/', wp_parse_url( sanitize_text_field( $_SERVER['REQUEST_URI'] ), PHP_URL_PATH ) ); $request_uri_path_count = count( $request_uri_path ); if( $request_uri_path_count == 0 ) { $category_id = 0; } else { $category_id = $request_uri_path[$request_uri_path_count - 1]; if( empty( $category_id ) ) { $category_id = $request_uri_path[$request_uri_path_count - 2]; } }
Thanks,
@awijasa
I edited my original workaround since it wouldn’t work on multisite.
Your code works, but not perfect. The category pages are not empty yet, but with more template issues.
Hi @selenii,
Thanks for the feedback! Would you mind sharing more about the template issues you are dealing with? If you have the chance please post an Answer with some screenshots or reply with the steps to reproduce the errors/issues you are seeing.
I may be able to help.
Thanks,
@awijasa
Issue is with the css. Look on this link https://rosadonna.ru/consultation/categories/psychology/
All other pages of anspress are working very well.
Hi @selenii,
Yeah, I am seeing a problem with https://rosadonna.ru/consultation/question/strah-v-obshhenii-s-lyud-mi/ where there are ads that jump into the content of questions and answers. Due to that, the main content bleeds into the right sidebar.
I would fix the main content bleed by adding a CSS into .post-in:
width: 100%;
I’m not sure if you really want the Google Ad to jump into the content of a question or answer. Let me know if that’s indeed your intention.
I apologize in advance if I misinterpreted the CSS issues you have. I just went with my instincts to determine what would be CSS problems on the site you shared.
Thanks,
@awijasa
The problem is, that your code shows the single.php page and not a anspress page, how can I change that?
Hi @selenii,
This might be related to @rahularyan’s post: https://anspress.io/questions/question/version-4-1-0-new-form-and-validation-class-8/. He mentions that:
All pages of AnsPress is now following WordPress template hierarchy. Single question page behave like an actual single page. This change in AnsPress will make sure that 3rd party plugin and widgets will work as expected.
So, I guess your category page is now trying to pick archive.php as a template. It may somehow fall back to single.php.
Due to the way 4.1.0 works now, you may need to add your own archive.php to format the way a category page looks.
In my installation, the category page is being formatted by archive.php.
You may want to wait for @rahularyan’s input on this one. Please note that I don’t work for AnsPress. I’m just helping out because AnsPress is so awesome and addicting 🙂
Thanks,
@awijasa
Thank you very much I will try to look for archive.php
Hello Guys,
Yesterday I made a fix for this bug, please check if updating to latest commit fix your issue.
Category page loads categories page template but it may change in upcoming version we may end up using taxonomy archive template. You can check below link for more detail.
Let me know if you need information. Cheers!
Thank you Rahul, but could you pleas make this update available on wp.org? For is this the bette way to update all wp plugins.
Thank you
Hello,
Have you override category template in previous version? If so, please make sure to update with latest category template.