Skip Navigation

[Resolved] Unpublished content in a relationship still appearing in views

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 13 replies, has 2 voices.

Last updated by derekD-2 4 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1480803
Screenshot_1.jpg

I have a Content Type called 'Vendors' and a Content Type called 'Promotions'. These content types have a one-to-one relationship, where a Promotion can be assigned to a Vendor. There is then a View that displays all active promotions, showing vendor details, and a short description of the promotion.

When a Promotion Post is Scheduled, in Draft, or Pending review, they appear in the active promotions view as if they are published. Only trashing them removes them from being displayed.

We have over 100 promotions to schedule, so this needs to be corrected. What is the proper way of filtering out related unpublished content? This is not working as expected.

#1480919

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-01-27 at 9.44.28 AM.png
Screenshot 2020-01-27 at 9.44.19 AM.png

Hi Derek,

Thank you for getting in touch.

If you go to your view and edit it then scroll down to the query filters. You should be able to add a query filter for Post Status. See Screenshot.

From there you can select the "publish" status.

Please let me know if this helps.
Thanks,
Shane

#1481045
Screenshot_2.jpg

Thanks Shane,

I tried this previously (and just tried again), with no change in the view output.

Is there a way to specifically target the post status of a related post?

Derek

#1481305

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Derek,

Is there a way to specifically target the post status of a related post?

No there isn't, the post status is really just filtered by that static filter for the status.

Would you mind allowing me to have admin access to the site to see what exactly is happening as your view should only be displaying the status of posts where they are published.

Thanks,
Shane

#1481309

Yes I can.... is this thread private? Where can I send login details?

#1481395

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Here are the private fields.

#1481423

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

HI Derek,

Could you let me know a post that shows up that shouldn't be showing in the view ?

I managed to find a post that has the same title but one is published and the other isn't

Take a look here.

hidden link

Thanks,
Shane

#1481437

Promotions are what become visible when scheduled. I have just scheduled "Purchase 2 meals & get a free side": hidden link

And it appears on this page, even when scheduled (not published): hidden link

Thanks!

#1482983

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Derek,

Did you change anything, i'm not seeing your scheduled item of "Purchase 2 meals & get a free side" all i'm seeing for scheduled is "Free drink with purchase of a dinner" and this is not showing up on the frontend search here "hidden link"

I'm also testing to see if the view actually displays scheduled items and it doesn't here
hidden link

However I believe I know what is happening here.

With this you are still able to display the information of the post
<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:90%">
<p>[types field='promotion-description' item='@vendor-promotion.child'][/types]</p>
</div>

Even though it has not yet been published.

What you perhaps need to do is to run a check on the post to see if it is published. Like this.

[wpv-conditional if="( '[wpv-post-status item='@vendor-promotion.child' ]' eq 'publish' )"]

<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:90%">
        <p>[types field='promotion-description' item='@vendor-promotion.child'][/types]</p>
    </div>

[/wpv-conditional]

This could perhaps resolve the issue since you only want to display the information when its published.

Thanks,
Shane

#1483001

Sorry, the client is in there making changes too (they are eager to have this working).

I've also just noticed that I am now not able to assign a vendor to a promo (relationship box is grayed out). Have you made any changes there?

I will also try the conditional output method you mention.

Derek

#1483017

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Derek,

No I have not made any changes to the website.

My suggestion was made through checking the view. Nothing has been touched.

Thanks,
Shane

#1483157

Why would relationships suddenly not work?

I cannot create a one-to-one relationship anymore between a promotion and vendor anymore. I've disabled the original and have tried many variations. Relationships simply do not work...

Can you investigate?

#1483187
Screenshot_3.jpg

P.S. The new conditional filter works great... but I am unable to make new relationships as per my previous comment.

#1483457

Outstanding relationships issue seems to be isolated to the live hosting environment. I will investigate further.

Otherwise, thanks for the help! The conditional statement you provided did the trick.