Dear Minesh, I've tested it - slight improvements needed. can you please take a look at my comments in code below:
function func_topic_mirror_id($atts){
global $post;
//added line WE GET POST ID EXAMPLE 333
//$post_id = get_post( $post->ID, array( 'fields' => 'ids' ) )
$tag_id = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
$cat_id = wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) );
//HERE WE HAVE TO UNDERSTAND WHAT VALUE OF sht-cf-type IS IN POST ID 333
$options = get_option('wpcf-fields');
$field_opt = $options['sht-cf-type']['data']['options'];
$all_opt = array();
foreach($field_opt as $k=>$v):
$all_opt[$v['value']] = $v['title'];
endforeach;
//HERE WE HAVE TO COPY TEXT OF sht-cf-type FROM POST ID 333 TO TARGET FIELD tscf-topic-mirror
if($cat_id[0]==4 and $tag_id[0]==11){
return $all_opt[5];
}
else if($cat_id[0]==5 and $tag_id[0] ==12){
return $all_opt[3];
}
}
add_shortcode( 'topic_mirror_id', 'func_topic_mirror_id');
Yes, to be more specific:
After testing we understood that we have to copy text value with logic:
[sht-cf-type] value from specific post (that is '5' in post ID '373') to post form '992' field [topic-mirror-id] should be like 'А.Н.Медведев - Группа Цигун...'
sorry - what you wrote is certainly not clear to me at all.
Do you mean when you save the form - you want to save the ID (that is '5' in post ID '373') and when display the form - show the text 'А.Н.Медведев - Группа Цигун...'?
No, no, everything that been done - ok, we still need to put a text value into the form when we save it. The only adjustment - we should derive respective text value not from combination of TAG + CATEGORY - but ... from only one custom field [sht-cf-type] which is filled in every post or page...
Now, you just need to save the value to database? If no - please explain in brief with step by step example and with few screenshot so that I can understand your requirement.