Skip Navigation

[Gelöst] Conditional output stoped working

This support ticket is created vor 5 Jahre, 8 Monate. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 2 Antworten, has 2 Stimmen.

Last updated by davidZ-4 vor 5 Jahre, 8 Monate.

Assisted by: Nigel.

Author
Artikel
#1088200

I am trying to: display posts (non protected) in a view

Link to a page where the issue can be seen: hidden link

I expected to see: non protected posts on the page

Instead, I got: no results at all

i use the fallowing in my view loop output editor:

 <wpv-loop>
            [wpv-conditional if="( '[is-protected]' ne '1' )"] <div class="col-sm-4">
      
      [wpv-post-body view_template="Memorials list for search"]</div>[/wpv-conditional]
    </wpv-loop>

it use to work in the past and now for some reason now it doesn't. i don't recall any updates i made recently.
when i remove the conditional output i get all the results on the page but with protected posts (that i want to hide)

 <wpv-loop>
           <div class="col-sm-4">
      [wpv-post-body view_template="Memorials list for search"]</div>
    </wpv-loop>

i have created and registered the shortcode [is-protected] as instructed here https://toolset.com/forums/topic/omit-private-posts-from-view-via-filter/#post-367945

please advise, how i can hide the protected custom posts from the view.
thanks,

David

#1088372

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

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

Hi David

I don't know what's in your custom shortcode, but in any case a better solution is to use the wpv_filter_query filter so that the query doesn't return any protected posts in the first place.

(Your solution means running the conditional check for every iteration of the results.)

You can do that with the following code:

function tssupp_omit_protected_posts( $view_args, $view_settings, $view_id ){

	if ( in_array( $view_id, array( 204 ) ) ) { //Edit for IDs of Views

		$view_args['post_password'] = '';
	}

	return $view_args;
}
add_filter( 'wpv_filter_query', 'tssupp_omit_protected_posts', 101, 3 );
#1090493

Hi Nigel,
When I tried your code on the site it didn't work.
I do see why it make sense to use the approach you suggested and I will give it another shot later on.
the way I solved the issue was to update WP, theme, and all plugins. it did the trick and everything is working as it was designed for. I hope this close the issue...

Thanks for the help.
David

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.