How to get all tags of a custom post type by id

Loop approach: usually archive-{custom_post}.php file.

FIRST:

custom_post_plural Stands for a group of custom posts of certain type.

Example of custom_post_plural: products

custom_post_singular Stands for an individual custom post type.

Example of custom_post_singular: product

SECOND:

var $args_custom_post_plural are the parameters of the WP_Query.

var $custom_post_plural is the execution of the query.

I used var $custom_post_plural_output to iterate the content of the WP_Object, specifically with the posts term, making the content of it “array friendly”.

As you can see I partially used Ahmad instructions for a nested iteration.

$args_custom_post_plural=array(
   'post_type' => 'custom_post_singular',
   'post_status' => 'publish', 
   'posts_per_page' => -1, 
   'fields' => 'ids', 
   'order_by' =>'id', 
   'order' => 'ASC'
);
$custom_post_plural = new WP_Query($args_custom_post_plural);
$custom_post_plural_output = $custom_post_plural->posts;
for ($i=0; $i < count($custom_post_plural_output); $i++) { 
   $tags = wp_get_post_tags($custom_post_plural_output[$i]);
   $buffer_tags="";
   foreach ( $tags as $tag ) {
      $buffer_tags .= $tag->name . ',';
   }
}
echo $buffer_tags;

FINALLY:

FYI If you want to use this in a single-{custom_post}.php file, you can use the following code:

$tags = wp_get_post_tags($post->ID);
foreach ( $tags as $tag ) {
   $buffer_tags .= $tag->name . ',';
}
echo $buffer_tags;

Since you must have a linked post in order to display anything.

Happy coding.

PS.
@cjbj Why in the hell did you erase my edit, it has something wrong or what?
Awful management here, and very malicious since I can’t respond to a comment due to my reputation points amount.