I am trying to: filter CPT with Post parent filter
Exactly as here: https://toolset.com/forums/topic/view-of-pagesposts-within-a-taxonomy-term-and-that-not-have-a-parent-page/
"Hierarchical" in CTP is checked
Result is - without filtering
On the other side - when I filter CTP to get child in parent CTP (something like images in galleries) - this is working perfect.
Dear tomas,
It is abnormal, I can not duplicate same problem, I suggest you check these:
deactivate other plugins and switch to wordpress default theme, and test again
Hi Luo,
I have done it - all non-toolset plugins off with delfault theme - result is the same...
Could you fill below private detail box with login details of your website?
Also point out the problem page URL and view URL, thanks
Please point out the problem page URL and view URL, thanks
can you provide private reply please? thank you
I just enabled the private detail box again. thanks
Since you provide me the credentials, which username is "Minesh", so I can login into your website with username "Minesh",
And you are using 19 plugins and custom theme, I need your permission to deactivate plugins and switch theme, please back your database first, thanks
I have done backup as I mention above and I already try to switch all non-tooset plugins and theme but the problem with filtering to show only top level posts with no parent persist.
So you can try it by yourself but for now there is Minesh logged in trying to resolve other problem I have with pagination...
OK, please update this thread when your website is ready for debug, and I will check it again in tomorrow morning. thanks
Hi Luo,
site is ready - for now I am continue with creating website - but tomorrow morning (HK time) it will be ready for you with backup.
Thanks for the details, check it in your website, will feedback if there is anything found
Your case is different from the thread:
https://toolset.com/forums/topic/view-of-pagesposts-within-a-taxonomy-term-and-that-not-have-a-parent-page/
Above thread is using the Hierarchical custom post type, but you are using parent/child relationship created with Types plugin, see the settings of post type "BAF":
hidden link
in section "Parent Post Types", you have setup post type " Galleries" as the parent post type.
I assume you are going to display those BAF posts which do not have a parent "Galleries" post, it needs custom codes, I added below codes into your theme/functions.php:
add_filter( 'wpv_filter_query', 'no_parent_baf_func', 10, 3 );
function no_parent_baf_func( $query_args, $view_settings, $view_id ) {
if($view_id = 403) {
$query_args['meta_query'][] = array(
'key' => '_wpcf_belongs_galleries_id',
'compare' => 'NOT EXISTS',
);
}
return $query_args;
}
More help:
https://toolset.com/documentation/user-guides/views-filters/wpv_filter_query/
Thanks Luo - it is now working this way now
but it stops working other way - now the filter to show child posts (BAF) in parents posts (Gallery) is not working...
I am little bit confused about what is different in Parent/Child and hierarchical if in hierarchical you must use Parent/Child relationship...
and one more question:
how to set up the code you add to functions.php to all views?
Q1) In other cases, for example:
now the filter to show child posts (BAF) in parents posts (Gallery) is not working
You will need to create another view for it.
Q2) I am little bit confused about what is different in Parent/Child and hierarchical if in hierarchical you must use Parent/Child relationship...
They are different, the hierarchical post type is a feature of wordpress, we use it in only one post type, for example:
Custom post type A
--Parent post 1
---- Child post 2
------ Grandchild post 3
see document:
https://codex.wordpress.org/Function_Reference/register_post_type#hierarchical
hierarchical
(boolean) (optional) Whether the post type is hierarchical (e.g. page). Allows Parent to be specified. The 'supports' parameter should contain 'page-attributes' to show the parent select box on the editor page.
The parent/child relationship pot types created with Type plugin, which is take effect on two post type, one is parent post type, the another is child post type, for example:
Post A (Parent post type A)
-- Child post B1 (Child post type B)
-- Child post B2 (Child post type B)
-- Child post B3 (Child post type B)
https://toolset.com/documentation/user-guides/creating-post-type-relationships/
Q3) how to set up the code you add to functions.php to all views?
The codes I provided is only an example, you can customize it by yourself, for example, you can apply it to two or more views:
Replace this line from:
To:
if(in_array($view_id, array(123, 456, 789))) {
Please replace those number 123, 456 with the specific Views ID, when you edit a view, you can get the Views's ID in the browser URL.
And it is not recommended to apply the same filters to all of your Views, it will conduct some unexpected result.