Post Data Title: generate from other field
-
Hi!
I have a request similar to the following topic:
https://www.ads-software.com/support/topic/generate-post-title-from-another-field/
I tried to adapt the code from the link in the question. However, I wasn’t able to make it work.
Let me explain in more detail:
I have a custom post type and I use a Forminator form to gather information about the customer and populate fields in the post. The post generation works nicely, however I’m always forced to use either Title or Content in order to be able to pass on meta values to the post. Since the custom post has it’s own title field, I had to “mask” the Post Data Title field as being for “administrative use” and have the customer write two titles for their entry.
Following the example from the link above, I created a code snippet to replace the title with the value of {text-1}.
<?php add_action( 'wp_footer', function(){ ?> <script type="text/javascript"> jQuery( document ).ready(function($) { $("#postdata-1-post-title").prop("readonly", true); $('#text-1-field').change(function() { var title = jQuery('#text-1-field').val(); jQuery("#postdata-1-post-title").val(title);}); }); </script> <?php } );
Unfortunately, this doesn’t work and I couldn’t find a way to adapt the solution proposed by Patrick Freitas to be used as a code snippet.
Thanks in advance for helping.
Best
Olivier
- The topic ‘Post Data Title: generate from other field’ is closed to new replies.