selected = bpy.context.selected_pose_bones
for bone in selected:
every time i run this it the contstraints on the same pose bone not on all the pose bones.
does anyone know how to make it add a constraint on every selected pose bone .
Best How To :
bpy.ops.pose.constraint_add() is an operator that only effects the active item, in this case a pose bone. While you are looping through the bones in the selection you aren't using the reference to each bone as you loop through.
Instead of using an operator you can manually create the constraints on each specific bone and adjust other parameters as you go.
for bone in bpy.context.selected_pose_bones:
nc = bone.constraints.new(type='COPY_ROTATION')
nc.target = bpy.data.objects['Armature']
nc.subtarget = bone.parent
nc.influence = 0.5