I currently have a many to many relationship between 2 post types, 'home designs' and 'land packages'
I am creating a content template for 'single land packages' and have created a view inside to display content from the related home design. I choose the option 'home designs related to the current land package' as the content selection. However when i then try to add a block to the loop in the view, the post source always defaults to 'current land package' instead of 'related home design'.
This functionality seems to be incredibly buggy to me.
The screenshot shows the selected view and the content that it should be displaying in the right. However you can see that the image block i have chosen in the content template defaults to current land package.
Its worth noting that i do have posts set up and related to each other.
Hi, I see what you're describing in the screenshots and I agree it is confusing to see the Current Land Package default option for this block. If I understand correctly you are desigining a Content Template for single Land Packages. At the top of the editor page, you should be able to select a Land Package post to use as the source post when editing the template - "View with: Post title". Can you tell me if the selected Land Package post has any related Home Designs assigned in this many-to-many (M2M) relationship? If not, please select a Land Package post that does include related Home Designs. This should help you design the View of related posts more effectively.
In a local test, I was able to set up a similar scenario with an M2M relationship between two custom post types, Rank and Chapter. I created a template for the Rank post type and in it, I created a View of related Chapters. In the loop of this View, when I insert a Single Field block, the default post selection is the Chapter post type, which is the post type displayed in the results of the View (see the screenshot here for my example). In this case, the Rank post I selected to preview the template does have associated Chapter posts. I suspect that the problem here occurs when a source post does not have associated Home Design posts, but I may need to investigate more.
Yep, i checked that the post being used as the 'view with' is indeed linked to home design with a m2m relationship. however it is still not working. The view still states that there are no posts to display from the query.
can i send you logins to take a look?
Yes or course, please provide login credentials in the private reply fields here and I'll be glad to take a closer look.
I saw some unusual behavior in wp-admin, but I think I have resolved it. The View was configured properly as far as I could tell, but produced no results on the front-end of the site. I looked for the cause and eventually ended up in the M2M Relationship setup. It seems that for some reason the intermediary post type did not exist. Either it was deleted or not created automatically as expected during the post relationship setup. If it was deleted accidentally, that could be the cause of the problem here, since it is necessary for the functionality of an M2M. I triggered the automatic intermediary post type recreation process by editing this relationship and then clicking "Add fields", as though I was going to add custom fields to the relationship. This kicked off the process that automatically generates an intermediary post type, since those are necessary for custom field storage. I didn't actually add any fields, but you can see the process was initiated in the screenshots here, along with the resulting intermediary type now displayed in the Relationship editor screen.
Then I updated the View's Content Selection settings to regenerate the appropriate Query Filter, now that the intermediary post type exists. Finally I can see results appear on the front-end of the site and the behavior of the View in the Block Editor is more like I would expect. I dragged a new Single Field block into the loop, and the default selection is now the current Home Design. That's what I would expect in this case. Can you take a look and confirm this is now working as expected?