Skip Navigation

[Resolved] Hide some content on the post archives page

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 25 replies, has 1 voice.

Last updated by amanT 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2807913

Tell us what you are trying to do?
Is it possible to hide certain posts from the post archives page, specifically the ones included in a particular Toolset View I've created? I added some custom PHP code to hide them using "add_action('pre_get_posts', 'hide_reviewed_books_for_user')" Function, and it works initially. However, when I use filter options or pagination, the hidden posts start appearing again. What are my options to fix this? I can share the PHP code I used if that helps
Is there a similar example that we can see?
none
What is the link to your site?
hidden link

#2807921

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I will have to review the code and how exactly you are hiding the unwanted post currently.

Can you please share problem URL and admin access details as well as share informtion where exactly you added the code and what is your expected results and with what filters I should try to filter the archinve in order to see the issue.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2807991

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked the "Code Snippets" section but I do not see the Button44(Name) snippet.

Can you please share direct link where you added the code snippet?

I have set the next reply to private which means only you and I have access to it.

#2808018

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for sharing the code snippet link but I do not understand the logic behind the code you added.

Especially why you are mering the $reviewed_books and $books_to_hide?

   $hidden_books = array_merge($reviewed_books, $books_to_hide);

Can you please tell me what is the use of $reviewed_books?

#2808062

because I want to hide all books that match either of these two rules:

Books the user has already reviewed

Books whose authors don’t have enough points.

And $reviewed_books is a list of books that the logged-in user has already reviewed

#2808165

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok.

First of all, when I checked the plugins page I find that you are using the outdated Toolset plugins. We always recommend running your site with the latest stable release plugin version.

*** Please make a FULL BACKUP of your database and website.***

Could you please update ALL Toolset plugins to it's latest officially released version. You can download the latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/
OR
You can install/update Toolset pluigins using the installer plugin:
-https://toolset.com/faq/how-to-install-and-register-toolset/#automatic-installation-once-you-have-otgs-installer-plugin-installed

Once you update ALL plugins to latst version, is your issue persists? if yes:

Could you please try to resolve your issue by deactivating all third-party plugins as well as the default theme to check for any possible conflicts with any of the plugins or themes?
- Do you see any difference? if no:

Please send me duplicator copy of your site:
- https://toolset.com/faq/provide-supporters-copy-site/

I have set the next reply to private which means only you and I have access to it.

#2808590

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can use the:

global $WP_Views;

And then check the $WP_Views object and see if you able to retrive the view ID.

For example:

global $WP_Views;

echo "<pre>";
	print_r($WP_Views);
	exit;

But first of all you should update ALL plugins to latest version.

#2808751
Screenshot (341).png

As you can see in the screenshot, I'm unable to retrieve the View ID. I guess this might be because it's a WordPress Archive and not a standard Toolset View. Could you please clarify whether it's possible to edit elements like query filters in Toolset Archives the same way as in Toolset Views? Also, is there a way to access and edit the archive view directly in the backend?

#2808794

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - we can debug this further once you update all plugins and theme you use to latest version.

Alternatively - you can share the staging site where I can eanable/disable plugins that should help us to troubleshoot this issue further.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2809701

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please update ALL plugins to latest version as I requested before and then I will check further.

#2809715

Done, Updated all the installed plugins to latest version

#2809723

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Have you checked I can see the pagination is wroking.

#2809733

On the demo site, I’ve added two types of pagination: wpv-pagination-nav-links (blue) and ct-pagination (yellow). On the main site, only wpv-pagination-nav-links is being used. Both paginations are currently facing issues with how the View displays content.

For the blue pagination, it initially shows only 4 pages, which is correct, but when you navigate to another page, it unexpectedly starts displaying all the previously hidden books, causing the number of pages to increase.
The same issue occurs when applying filters, books that should remain hidden appear, and the pagination updates incorrectly.

On the other hand, the yellow pagination always displays 4 pages regardless of the filter results. Even if the filtered results contain only 8–10 books, the pagination doesn't update to reflect that and still shows 4 pages.

If you test all the filter options and pagination thoroughly, you’ll notice these issues consistently

#2809748

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

On this page: hidden link

First it shows four pages.

Then I appy the filter "Book categories" and selected the option "Action and Adventure" it filters the results correctly and shows 2 pages as results.

Is this correct? if yes:

When I click on page 2 link it redirect me on 2nd page and it does not show 4 pages.

#2809765

Update: The pagination issue is resolved. I enabled "Pagination with manual transition and page reload," which fixed the problem.
But if I can achieve the same using "Pagination enabled with manual transition and AJAX", that would help.

Now, regarding the filter options in the custom search: when I set it to "Full page refresh when clicking Submit" and include a submit button, it works correctly and returns the expected results. However, I want to use "AJAX refresh when changing any filter" instead, so that the results update automatically whenever a filter is selected, without requiring the user to click a submit button.

How can I achieve this functionality?

(You can try enabling both "Pagination with manual transition and page reload" and "Pagination enabled with manual transition and AJAX" to better understand the behavior.)