[Resolved] Remove post relationship instead of deleting post.
This thread is resolved. Here is a description of the problem and solution.
Problem:
From a parent post edit screen it is possible to add new child posts but not assign existing ones. The child posts can be deleted, but can they simply be removed (i.e. unassigned, rather than deleted)?
Solution:
Not with the current implementation, but these will be possible with the imminent update to Types 3.0.
This support ticket is created 6 years, 10 months ago. 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.
Tell us what you are trying to do?
We have Newsletters that contain Articles. Both are custom post types. Articles can belong to Newsletters. When I click "Add new Article" under the Newsletter edit page, it creates a new article instead of listing articles that can be associated with that newsletter. Can existing articles be linked from the Newsletter edit page?
When Articles are linked to a Newsletter, there is only a Delete button. Could Articles be removed from being related to a Newsletter, and not deleted?
How can we set the display order of linked Articles in a Newsletter?
Is there any documentation that you are following?
No
Is there a similar example that we can see?
The site itself.
Just another quick update... when deleting an Article from a Newsletter via the Newsletter edit page, the Article doesn't go to the trash where it's recoverable. It permanently deletes it. At the very least, shouldn't the delete button put things in the trash?
Your observations are correct about the current implementation.
You can add new child posts from the edit screen of a parent post, but not assign existing ones.
You can delete child posts, but not un-assign them.
For each of the above you must do it from the child post edit screen, where you can assign, or un-assign, the parent.
We won't be making any changes to this because the post relationships UI is about to change completely. There have been quite a few posts about this on our blog, and you can try out the betas with the new UI from your downloads page (wp-types.com/account/downloads) by selecting the beta channel. (You will want to do this on a test site.)
Do you know, is it possible to set the display order of linked Articles in a Newsletter?
The "Newsletter" is the parent of "Articles", but we'd like to rearrange the order of the Articles in a Newsletter.
Here is an example: hidden link
The articles are ordered in the left sidebar the same way they appear in the Newsletter post relationship window, but I can't move #1 up to the first spot. We have over 1600 Articles and need a way to arrange them within each Newsletter. (About 15-20 articles per newsletter.)
I would expect you to create a View that shows articles and has a filter to display articles that are children of the current newsletter, though looking at the page source it is not obvious that's what you've done.
If you do generate the list in that way then you have the normal options available to you to order the results of a View, e.g. by fields such as post title, post date etc.
If a custom template is generating that list it must be running a custom query to retrieve the list of child articles, and the same options for ordering are available to it as would be available in a View (which is just a UI-friendly wrapper for WP_Query).
There is one orderby option which can help you out here, and that is the little-used/known 'menu order'.
If you look at a hierarchical post type such as pages you will see a Page Attributes meta box that contains a numeric field for order.
It would be tedious to manually update the number to change the order of such posts, and there are at least two plugins that provide a drag 'n drop function to re-order posts. I haven't used either but their purpose is to provide a user-friendly means of changing the menu order field so that you can then use it in your custom queries to output posts ordered by this menu order field.
I had one last question... we have some Articles and Events custom post types that need to belong to multiple Newsletters custom post types. Right now I can only assign an Article or Event to a single Newsletter. Is it possible to be able to assign them to multiple Newsletters? For example, a conference Event in October can be assigned to appear in a March Newsletter and June Newsletter at the same time.
For example, if every 30 Articles (of 1,600 total) need a different Volume and Number, I can't select 30 Articles and mass edit the Volume custom field value. (I may need to use WP All Export and WP All Import?)
Lastly, is it possible for Articles custom post types to inherit custom field (or taxonomy) values from the parent Newsletter? For example, if an Article has a custom field value for Newsletter Volume (e.g. Vol. 10), and a Newsletter has a custom field for its Newsletter Volume (e.g. Vol. 10), can the Article custom field value be assigned when its post relationship is attached to the parent Newsletter? I suppose this would complicate things if an Article were attached to multiple parent Newsletters with different Volumes.
Sorry for the delay getting back to you, it was a long weekend here in Ireland.
* With the current implementation posts can only have a single parent of a given type, so you cannot assign the same article to more than one newsletter.
That restriction will be gone in the new version.
* Bulk edit custom fields? No. Exporting then re-importing would be the way to go.
* I think what you want here is to use the WordPress save_post hook so that whenever an Article post is saved a snippet runs which gets fields from the parent Newsletter and reproduces them on the Article (if not simply duplicating then manipulating then saving): https://developer.wordpress.org/reference/hooks/save_post/