Skip Navigation

[Resolved] Show posts with custom post status in views

This thread is resolved. Here is a description of the problem and solution.

Problem:
Search for posts with custom post status in views not working
Solution:
I checked it and the issue was with the third filter: Filter by post relationship or repeatable fields group owner.

With it disabled, the filter by status was working fine.

I checked it and it seems like the Owner participates of two different relationships. By selecting the only one relationship, it somehow was impacting with the status filter.

I changed it slightly, updating it to check if the current item in the loop has any relationship with the current owner.

And that seems to have fixed the issue.
Relevant Documentation:
https://developer.wordpress.org/reference/functions/get_post_statuses/
https://developer.wordpress.org/reference/functions/update_post_meta/

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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 4 replies, has 3 voices.

Last updated by Mateus Getulio 9 months, 2 weeks ago.

Assisted by: Mateus Getulio.

Author
Posts
#2686246
query.JPG

I'll try to explain my issue in the best possible way!

I have used a plugin (called Extended Post Status) to create a Custom Post Status (the new status is "Archive")
When I use a View to retrieve all posts (including the "Archive" ones) everything shows up as expected!

I have also created another View - using some filters:
I display Posts that are Related to another Post, the author of which, in the same as the current logged in user.
Again this view shows everything fine (even draft, pending, password protected posts) APART from the "Archive" ones.

Any ideas on this one please?

#2686268

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

There is an internal filter that controls the accepted post statuses, you could try adding the following code (e.g. at Toolset > Settings > Custom Code) and see if that works:

add_filter( 'toolset_accepted_post_statuses_for_api', function($stati){

    $extra_statuses = array( 'archive' ); // array of the extra post status slugs you want to add

    return array_merge( $stati, $extra_statuses );
});
#2686300
Capture.JPG

it's not working. maybe it's another hook that we should use in order to achieve this functionality?

#2686509

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

I'm not sure the case would impact, but it seems like the status was created with the capital A. Just as a test, can you please change the code looking for the post status 'Archive' to see if it causes any changes?

If not, I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://toolset.com/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

**IMPORTANT**

- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link

Please, let me know if you need any additional details. Have a nice day.

#2687492

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

I checked it and the issue was with the third filter: Filter by post relationship or repeatable fields group owner.

With it disabled, the filter by status was working fine.

I checked it and it seems like the Owner participates of two different relationships, Male and Female. By selecting the Female relationship, it somehow was impacting with the status filter.

I changed it slightly, updating it to check if the current item in the loop has any relationship with the current owner.

And that seems to have fixed the issue.

Can you please test it again and let us know?

Mateus