Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
559 views
in Q2A Core by

I would like something plain vanilla, the "nav sub list links" adds no value in my case.

I would like to remove it safely. Currently, I hide it by using CSS tricks, but the links are still there and get indexed by Googlebot.

nav sub list

How to?

by
Wouldn't it suffice to add "Disallow: /index.php/questions?sort" (or whatever your URL structure is) to your robots.txt to stop Google from indexing them?

1 Answer

+1 vote
by
selected by
 
Best answer

Hello teddydoors,

There are two ways of disabling the sub navigation for the 'questions' page:

Method 1: Disable the 'sort' query parameter directly in qa-include/pages/questions.php by replacing this:

$sort = ($countslugs && !QA_ALLOW_UNINDEXED_QUERIES) ? null : qa_get('sort');

with this:

$sort = null;

in line 34; and then the sub-menu by replacing this:

$qa_content['navigation']['sub'] = qa_qs_sub_navigation($sort, $categoryslugs);

with this:

$qa_content['navigation']['sub'] = null;

in line 133; please have a look at 'Step 1' and 'Step 2' in this snippet , which already has these changes in place.

  • Pros: Quick and easy way of getting the job done
  • Cons: It'll get reverted to its initial form after updating Q2A

Method 2: Avoid modifying Q2A itself by creating a plugin and duplicate the parts you want to adjust into it. 

  1. Create a plugin. Here's a great tutorial on how to create plugins.
  2. Copy the file I mentioned in Method 1 into 'my_plugin'
  3. Override the route 'questions/' in qa_page_routing() so that it loads the duplicate in the plugin, instead of the one in Q2A.
  4. Adjust the contend of the duplicate so that you can follow Method 1 in the plugin itself.
  • Pros: It'll work after Q2A updates
  • Cons: The plugin needs to be updated manually after Q2A updates

Have a nice day.

by
+1
Thank you for your answer.

It's great that you can detect the root cause of the matter.

It's funny that in one of my old installations, I did the trick by commenting the line 133.

But you did a clever job of showing how things are to be done properly.

Thanks.
by
You're very welcome!
...