Are you referring to the default category that you set in the options panel? Which is “uncategorized” by default with a new install? If yes, then get_option('default_category'); will get you that much.
If you’re talking about something like “Primary Category” that Yoast makes use of then you may need a touch of custom code like what’s found at https://stackoverflow.com/a/38800804 to fetch regularly.
Otherwise, I’m not familiar with any other “default category” setups that you may be using, so I can’t provide any best ways to retrieve. Willing to hear what you have and offer potential suggestions once I know how the detail is stored.
Thank for your answer.
I created a custom post type : “Events”. I also created a custom taxonomy : “Categories”, for this custom post type. Well, I can set many “Categories” for a post created from the custom post (Events) : For example, for an new event, I can set “Party”, “Pool”, “Free” as “Categories”.
Then, I can define the main “Categories” for the new post. I can set that the main “Categories” is “Pool”.
Finally, My question is, how may I get the title, or the ID of this “Categories” set as default “Catégories” ?
Is it more clear ?
I definitely understand the concept and idea. It’s the “how is a specific category marked as primary” part that isn’t clear yet and still.
For example, is the UI to set the primary category looking like something in the first image at https://www.tannerrecord.com/how-to-get-yoasts-primary-category/ ? with a link to the right say “Make primary” ? If exactly that, then the Yoast SEO link there or the StackOverflow link from my previous reply will be your best bet.
Otherwise, I’d need to know how primary choice is being stored, what exactly is stored, and details like that, in order to provide any guidance.
Hello !
That’s exactly what I needed. Thanks for your answer ! I close the ticket.
Chris