Skip Navigation

[Gelöst] Conditional output stoped working

This support ticket is created vor 6 Jahre, 1 Monat. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von davidZ-4 vor 6 Jahre, 1 Monat.

Assistiert von: 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: versteckter 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

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

Zeitzone: 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

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.