Hi,
I am trying to create a form at http://www.customtoylab.com/show-us-your-toy/ so that it has a custom field for each seperate question asked at http://www.customtoylab.com/submit/ and automatically output the information like in the post http://www.customtoylab.com/2008/08/05/the-pantless-bunch-patrick-francisco/
I can not get the custom fields to display in the format of the post ocne submitted and the images do not show up only the links.
I also want the post to be [toy name] – [artist name] by automatically grabbing the information from the form.
Any idea how I should start
Thanks
I am trying to use TDO miniforms to allow my visitors to post their personal information on my site. I have used the widgets panel to create a from with 5 custom fields.
I want the post title to be the value entered for Custom Field 1.
The Title of custom field 1 is Name, the Key Field Name is “name”.
I have added an append to post content 1 field at the end of my form and inserted the following code:
$post_id,
“post_title” => $post_title;
sanitize_post($postdata,”db”);
wp_update_post($postdata);
?>
Can anyone tell me what I am missing. I am new to php and I am struggling to make this work. It seems like this should be an easy thing to do, but it is not working for me.
Thanks in advance
Hi Alan, I’m assuming part of your code got lost there when you posted. Something like this should work for you:
<?php
/* assuming you have called the custom field key "name"... */
$post_title = get_post_meta($post_id, 'name', true);
$postdata = array(
"ID" => $post_id,
"post_title" => $post_title;
sanitize_post($postdata,"db");
wp_update_post($postdata);
?>
Has anyone had luck doing this? I cut and pasted the code above that Mark Cunningham has provided. I put this this in an append to post box. The append to post box is the very last box on the form. Directly above that I created a custom field and I tied the custom field to the name field key. I can’t get it to work.
Scott Hack said:
Has anyone had luck doing this? I cut and pasted the code above that Mark Cunningham has provided. I put this this in an append to post box. The append to post box is the very last box on the form. Directly above that I created a custom field and I tied the custom field to the name field key. I can’t get it to work.
There is a little code syntax bug in it, missing a closing bracket:
<?php
/* assuming you have called the custom field key "name"... */
$post_title = get_post_meta($post_id, 'name', true);
$postdata = array( "ID" => $post_id, "post_title" => $post_title);
sanitize_post($postdata,"db");
wp_update_post($postdata);
?>
Hello,
I am trying to take the post name and add a date on the end of it. I have a custom field called ‘startdate’. As it stands, only the date shows up in the title. So, I’m sure that I’m not doing something right with the original title. Here is what I have tried:
<?php
the_title($display, false);
$date_title = get_post_meta($post_id, ‘startdate’, true);
$full_title = $display . ” ” . $date_title;
$postdata = array( “ID” => $post_id, “post_title” => $full_title);
sanitize_post($postdata,”db”);
wp_update_post($postdata);
?>
I appreciate any help!
When I use this technique, it works fine and my posts have the proper text. But in my admin dashpoard under Edit Posts, all the posts made with this approach are missing a post title. It just says “(no title)”
Is this correct???
Thanks!
Mark Cunningham said:
Scott Hack said:
Has anyone had luck doing this? I cut and pasted the code above that Mark Cunningham has provided. I put this this in an append to post box. The append to post box is the very last box on the form. Directly above that I created a custom field and I tied the custom field to the name field key. I can’t get it to work.There is a little code syntax bug in it, missing a closing bracket:
<?php
/* assuming you have called the custom field key "name"... */$post_title = get_post_meta($post_id, 'name', true);
$postdata = array( "ID" => $post_id, "post_title" => $post_title);
sanitize_post($postdata,"db");
wp_update_post($postdata);
?>
admin
Guest
August 8th, 2008 at 9:26 am
You should be able to enable, in the custom field widget, that the custom fields are appended to the post content and there is a field there to format them anyway you like.
As for image uploads, again there should be a number of options in the widget about how to display images. You have to have the file added as an attachment for a thumbnail, but it can be made to automatically generate the thumbnail and display it.
That is slightly more complex, but doable. You will need the Append Widget, in this widget you’ll have to add code to grab the values of those custom fields for toy name and artist name. This topic goes through the details of how to do it to use the username however you’ll have to do something different.
Add an Append Widget to the form, make sure it’s the very last/bottom widget. Then you can use this code or a variant of it in the Append Widget:
I haven’t tested this code, but I’m fairly confident it’s correct.
Permalink | Quote