boonebgorges / buddypress-docs

GNU General Public License v3.0
106 stars 44 forks source link

Recent docs widget not showing latest docs #711

Open ParkLai opened 2 years ago

ParkLai commented 2 years ago

When placing the Recent Docs Widget on a page, it always shows the first 4 (or the number set in "number of docs to show" setting) documents sorted by ID, instead of published date. Therefore the widget will always show the same docs regardless of the new documents being uploaded.

boonebgorges commented 2 years ago

Hello @ParkLai - The widget sorts by 'modified', rather than publish date. Can you verify whether this is the behavior on your installation?

You might help to debug by checking the doc_query object here, which should be a WP_Query with 'orderby' => 'modified'.

ParkLai commented 2 years ago

Hi @boonebgorges, think it sorts by ID, as it only shows the first few uploaded docs regardless of their modified date.

I'm looking at the file class-wp-widget-recent-docs.php, and tried adding the 'orderby' parameter to the $doc_args but still it doesn't seem to work.

Can you point me on which file and how should I check the doc_query object?

boonebgorges commented 2 years ago

Sorry, I meant to give you this link in the previous comment: https://github.com/boonebgorges/buddypress-docs/blob/d69ab86a2fe6c6f3a61dca6425bc60a9208c3949/includes/templatetags.php#L134=

$bp->bp_docs->doc_query should have the orderby query_var set to modified. My guess is that you have a plugin preventing this from happening.

ParkLai commented 2 years ago

Yes, you're right. Seems like the orderby has been set to title instead of modified. Tried using the filter bp_docs_default_sort_order to set it, but not working. Will check and see what's causing this issue.