Here’s a way to do it dynamically. This approach allows you to pass the post type as a parameter so you can use the same function with multiple post types without have to edit the code ever again.
Also here’s another old post showing how to do that
Here’s a way to do it dynamically. This approach allows you to pass the post type as a parameter so you can use the same function with multiple post types without have to edit the code ever again.
Also here’s another old post showing how to do that