Is it possible to add the ability to write in an authors twitter per post manually?
Hi, there is already an option for multi-author :
Options page > Custom Twitter Cards > Add a field Twitter to profiles > yes.
Then every single author can add his own Twitter Account as meta creator for his article.
I do not want the user to have to register. I want to be able to write in the author. Perhaps using a custom field.
OK I see you want a field in edit post. I can show you how to do that but you’ll have to add this by yourself. Can you do this?
Sorry their bbcodes are a little be tricky here !
Open jm-twitter-cards.php, add this line 58 :
//we add a new post meta to our post $creator = get_post_meta(get_the_ID(),'twitterCreator',true);
then add this line 71:
<?php //this is the markup for new field ?> <p> <label for="twitterCreator"><?php _e('Enter your Personal Twitter account', 'jm-tc'); ?> :</label> @<input id="twitterCreator" type="text" name="twitterCreator" class="regular-text" value="<?php echo esc_attr($creator); ?>" /> </p>
and last replace code on line 96 to 98 with this code :
// here you update value if( isset( $_POST['twitterCardType'] , $_POST['twitterCreator'] ) ) update_post_meta( $post_id, 'twitterCardType', esc_attr( $_POST['twitterCardType'] ) ); update_post_meta( $post_id, 'twitterCreator', esc_attr( $_POST['twitterCreator'] ) ); }
Wow, finally a dev on here that actually responds, and with a solution too!
But, the creator field is being over written. I can change the type but the creator is still being set to the account that is posting.
Hi, I’ve tested this code before. It adds a field and when input is fulfilled and post saved the meta creator is changed.
This is what you asked me for. I don’t understand.
I know, the form displays but the new creator is not being changed. The twitter:creator meta is still the user that is logged in, not the one i put in manually. Any idea why this happens?
probably because I forgot to mention line 162. You have to replace this line :
//content from the field in user profile $creator = get_the_author_meta('twitter', $post->post_author);
with this line :
// grab post meta from our new custom field $creator = get_post_meta(get_the_ID(),'twitterCreator',true);
It should fix the problem. 🙂
YES! There it is. This is awesome functionality. Thanks so much.
- The topic ‘Manual Authors’ is closed to new replies.