Skip Navigation

[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.

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+00:00)

This topic contains 14 replies, has 3 voices.

Last updated by fernandoM-9 6 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#624793

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.

What is the link to your site?
hidden link

#624795

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?

#624858

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Mike

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.)

The new workflow, including your above requirements, is described here: https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

We aim to have the production versions published shortly after the end of the month.

#624964

Thanks Nigel,

I'm looking forward to the updated plugin.

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.)

#624993

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Mike

How have you added that list of articles?

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.

#625002
2018-03-14_10-54-48.png
2018-03-14_10-53-54.png

Hi Nigel,

The site uses custom templates instead of views. I think it just displays the articles how they appear on the Newsletter page. (screenshot attached.)

I added the articles via the Post Relationship field when editing an article.
(screenshot attached.)

#625008

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

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).

See: https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

#625021

Is there a way to add a custom drag/drop interface in the admin?

The order is custom, based on the anesthesiologists determination of the best articles first, not by title, date, etc.

#625196

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

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.

https://wordpress.org/plugins/metronet-reorder-posts/
https://wordpress.org/plugins/post-types-order/

#625795

Thanks Nigel,

This has all been helpful.

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.

#625796

I just remembered a couple more quick questions.

Is there a way to bulk edit custom field entries?

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.

Thanks for bearing with my questions.

#626446

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Mike

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/

#627928

Thanks Nigel!

Looking forward to the new version. Is that still on track for release later this month or early next month?

#631687

Hi Nigel,

Was just wondering if the the next version of Toolset will be released soon, that allows for connecting/disconnecting pages/posts?

Thanks,

#1134091

Hey is this new feature released yet?