I have built a custom post type for saving music with a post. I have built a custom interface and uploader to allow members of my network to upload music they have created to their blogs. With this custom interface and uploader a post is created and post_meta (custom fields) are saved.
The issue I have just discovered is the post_meta is not being saved to the tags blog.
I am using have 3 steps to creating the custom post:
$postid = wp_insert_post($my_post); wp_set_object_terms( $postid, $atags, 'post_tag', false ); update_post_meta($postid, 'genre', $genre); update_post_meta($postid, 'subgenre', $subgenre); update_post_meta($postid, 'trackurl', $url);
Those are just a few of the custom fields being created. But none of them are making there way over to the tags blog. Im thinking I could trigger a post update of the just created $postid.
Is there a better or more WordPress way of either creating the post so that the post_meta is imported to the tags blog? Maybe I can add an additional hook within the plugin so it catches when post_meta is updated as well?
Does the post come through to the tags blog?
Did you add those custom fields to the post meta list in the SWT settings?
Yes I have all the custom fields in the settings, they all imported in with no issue.
Yes the post saves to the tags blog it just missing all of the custom fields.
Are you looking for them in the edit post area or on the front of the site?
I was looking directly in the database. At the post_meta table.
Looking at your code above
$postid = wp_insert_post($my_post); // <-- SWT copies the post to the tags blog inside of this function call wp_set_object_terms( $postid, $atags, 'post_tag', false ); update_post_meta($postid, 'genre', $genre); update_post_meta($postid, 'subgenre', $subgenre); update_post_meta($postid, 'trackurl', $url);
Do you have any suggestions for me? I tried addind a wp_update_post function at the end of my post creation, but that didnt seem to work.
Should I add some custom code into the SWT plugin to hook in the saving of tags and postmeta?
I have tried the following code to add a post update action which I was hoping would trigger the save_post hook.
$postid = wp_insert_post($my_post);
wp_set_object_terms( $postid, $atags, ‘post_tag’, false );
update_post_meta($postid, ‘genre’, $genre);
update_post_meta($postid, ‘subgenre’, $subgenre);
update_post_meta($postid, ‘trackurl’, $url);
$mypost[‘ID’] = $postid;
This didnt work. What I have found works is viewing the custom post/track in the custom editor I wrote and saving it.
Im using wp_update_post to update the post/track in my custom editor. So I dont understand why that doesnt work when I use it during my post creation.
Try setting the post status to draft in the first save and change it to publish before you update.
Its now working.
Thanks for the tip. I was actually misspelling my post ID variable so that was the source for the wp_update_post not working, but going from draft to published makes since here. I didnt discover it until I went in to edit the post_status.
Thanks again for your time and help.
- The topic ‘[Plugin: WordPress MU Sitewide Tags Pages] Post Meta not Saving to Tags Blog’ is closed to new replies.