I am trying to:
Remove the default value in setting up a Post Reference Custom Field. The field should offer a dropdown/searchable list of essays, but the default for the field enters, for some reason, the essay's category. I have a conditional to only display the field of reference is added to the field. The problem is that if I don't fill the field, the default (the category) gets activated, and I get a 500 error (because, the default category is not an essay!)
Link to a page where the issue can be seen: hidden link
This is happening on the backend - see images below.
I expected to see:
No default set inside custom field
Instead, I got:
A category as default entry of Post Reference
Hello. Thank you for contacting the Toolset support.
Well - the thing is that currently we do not support self-join relationships that means you should not use post reference field to connect same post type post and there was a bug with the RC plugins you were using that made it possible but we already fixed that bug and you will not be allowed to use post reference field to connect same post type.
Additionally, After checking debug information you shared with us, I found that you are using outdated Toolset RC plugins. We always recommend to run your site with latest stable release plugin version.
*** Please make a FULL BACKUP of your database and website.***
Could you please update ALL Toolset plugins to it's latest official released version. You can download latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/
We have plans to implement self-join relationship that will be implemented in near future release but you need to wait for that. There is no ETA on it.
Minesh,
Do you have any suggestion for how to show a link that connects one post to another of the same post type? Something that will be stable over time? Should I create a relationship?
Do you have any suggestion for how to show a link that connects one post to another of the same post type? Something that will be stable over time? Should I create a relationship?
==> as I try to explain - self-join relationship is not yet supported for now but our Devs have plan to implement it and its on roadmap but when it will be available for public use is not yet decided as this feature is still under assessment. There is no ETA on it.
I just updated the plugins and everything still works AND the default value has gone away. Problem solved?
==> No - you should not use it even though it works for you for now because - it will give you pain sooner or later when it stop working as this is not the way to use that field - I would suggest to remove that field completely from your custom field group.
I think I have a workaround to suggest - You should add a dropdown select field to your custom field group and fill its value dynamically.
Once you created the field - then you should use following hook to populate the dropdown select options dynamically.
For example - I've created custom field "select essasy" with your custom field group and then added following code to your current theme's functions.php file that is used to populate the dropdown with existing essay post type entries :
If you add/edit the essay post - you will see the "select essasy" is available to select the options and you can save the ID of the selected option with custom field "select essasy".
Minesh,
Thanks for the work around. But I have two remaining questions:
1) I tried to change the naming of the custom field to "riPOSTe to" instead of "select essasy" and failed to replicate the drop down menu of essays. Of course, I made sure to replace the "case" in the hook to reflect that name change, but I guess I missed some other change in the function. If I want to rename the custom field, what should I change?
2) In my attempt to insert this custom field value into an essay template, I am not understanding what to select for "Post Selection" when adding a field.
[wpv-conditional if="( NOT(empty($(wpcf-riposte-to))) )"]
<div class="riposte-link">A riPOSTe to: ????? </div>
[/wpv-conditional]
FYI: I would like to keep the older Post Reference custom field "riPOSTe" so I know which essays need it and then I will delete.
Another thing is that the current custom field - "select essasy" - has a default set to the first essay on the list. I need the default to be no essay as only a few essays will get an active field. In other words, this is a rare condition for an essay and that is why I have a conditional (see above) to only display if the field is filled.
1) I tried to change the naming of the custom field to "riPOSTe to" instead of "select essasy" and failed to replicate the drop down menu of essays. Of course, I made sure to replace the "case" in the hook to reflect that name change, but I guess I missed some other change in the function. If I want to rename the custom field, what should I change?
FYI: I would like to keep the older Post Reference custom field "riPOSTe" so I know which essays need it and then I will delete.
==> Well - as you want to have current connection - its not wise to rename the field as once you rename the field your connections will be lost. I suggest to create a brand new field as per your need and give it your desired name and then once you migrate all connections you should delete the "riPOSTe to" post reference field.
2) In my attempt to insert this custom field value into an essay template, I am not understanding what to select for "Post Selection" when adding a field.
[wpv-conditional if="( NOT(empty($(wpcf-riposte-to))) )"]
<div class="riposte-link">A riPOSTe to: ????? </div>
[/wpv-conditional]
==> We will deal each question one by one. Please open a new ticket for your each new question. This will help other users searching on the forum.
Another thing is that the current custom field - "select essasy" - has a default set to the first essay on the list. I need the default to be no essay as only a few essays will get an active field. In other words, this is a rare condition for an essay and that is why I have a conditional (see above) to only display if the field is filled.
==> Ok - I've changed the code as given under: