Filter by category in widget

4.68K viewsCorefilters shortcode widgets
1

I have created a new widget area on my template and created a widget that shows the last 5 questions. The problem I am having is that my site is split into 4 sections. I want to have those 4 sections in the questions/answers and I am wondering if I can somehow filter the questions by the posts category. Can I use shortcodes somehow or some how add a filter to the widget field?

0

Yes you can show filtered question by simply adding tag or category id in shortcode:

[anspress question_category="category_1,category_2" question_tag="tag1,tag2"]

You can also pass this arguments to anspress shortcode:

  1. tax_relation – OR or AND (relation between tag and category taxonomy). read more here Taxonomy.
  2. tags_operator – read more in given link.
  3. category_operator – read more in given link

Cheers.

Thank you again for your help. (Sorry it seems to lose all formatting in the comment. )

That works but it is not quite what I was after. When I do that it shows me the questions like using [anspress].

What I was trying to achieve was like the widget “(ansPress) questions”. Only showing 5 of the latest questions in that category and have them linked to the main ansPress site.

Basically I am looking for something like the following. Each of these lines would link to the question asked by the user and View all that goes to the full list of questions about that category.

Do I need to do XXXXXXXXXX?
Should I do XXXXXXXXXX?
When will I do XXXXXXXXXX??
How I did XXXXXXXXXX?
You should do XXXXXXXXXX?

VIEW ALL

I hope this make sense.

Thanks.

Its possible after some slight modification. I will give a detail answer after getting free.

Thank you. I appreciate your help with this.

Hi Rahul,

Have you had a chance to look into this problem?

Thanks.

As I said already, it will be added to 2.3. After completing remaining tasks I will work on it. Plsease keep an eye on github commit.

Hi Rahul,

Sorry to bring up an old topic. You mentioned that this feature may be added to 2.3. I can see some new features that may be related to this. Could you confirm if this has gone live and how this feature will work as I cant see anything on how it would work.

Thanks

Hi, Sorry I missed this task in our roadmap. But I just added this to AnsPress, now you can add category ids in question widget. Download here: https://github.com/anspress/anspress/archive/2.3.1.1.zip