[Closed] Views: Post parent is -not- specific 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.

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Luo Yang 5 years, 12 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#60179

There is no way to filter posts where a certain page is not the post parent.

This is inconsistent and prevents you from doing certain things. In my case I am fetching Media, but don't want media that is attached to a specific page.

Explanatory image:
hidden link

#60296

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Stanislav,

You are right, there isn't such a option for "filter posts where a certain page is not the post parent".
But you can try use Views [wpv-if] shortcode to check if parent post ID = certain page ID,
If not, output the result, here is the document about [wpv-if] shortcode:
https://toolset.com/documentation/views-shortcodes/#wpv-if

Similar as we talking about in thread:
https://toolset.com/forums/topic/checking-if-post-has-a-parent/

[wpv-if evaluate="'[wpv-post-id id="$parent"]' != 12345"]
This post's parent is not page 12345
[/wpv-if]

And Please let me know if you need assistance to do it

Regards
Luo

#67236

It works, but pagination gets screwed up, because you don't know if you're gonna get 1, 5 or 20 items on a single page.

Any way around that?

#67535

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

In your case, please try use Views filter "wpv_filter_query", like this:

1) add codes in your theme/functions.php

add_filter('wpv_filter_query', 'exclude_specific_page_func', 10, 2);
function exclude_specific_page_func($query, $settings) {
if ($settings['view_id'] == 123) {
$query['post__not_in'][] = 456;
$query['post__not_in'][] = 457;
$query['post__not_in'][] = 458;
}
return $query;
}

123 is your Views post ID, 456~458 is media post ID you want exclude

#68669

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Sorry, we don't have this feature in Views plugin. I've added it to our feature list for review.

The topic ‘[Closed] Views: Post parent is -not- specific page’ is closed to new replies.