Get primary category

WordPress
20 December, 2022 01:28:04
expedientnl
Topics: 1
Messages: 3
Is it possible to output the primary category in e2pdf?

I'm currently using this to select the first category selected, if multiple are selected:
[e2pdf-wp key="productcategory" terms="true" path="0.name"]

However if the order in which the user selects the categories is different for another post then another category will be output, as the first one selected is at 0. Is it possible instead to output the category that has been made primary? See attached img.
20 December, 2022 02:04:04
E2Pdf
Support
Topics: 7
Messages: 3188
Hi,

Can you please clarify which plugin is used for "Primary" category functionality, as by default WordPress doesn't have such feature? Is it Yoast SEO? Or some other?
We would really appreciate your feedback at WordPress.org!
20 December, 2022 02:10:26
expedientnl
Topics: 1
Messages: 3
Hi, Ah, yes this is from Yoast SEO. Is this (of another plugin of functionality) still usable to select a specific category instead of the path number selector?
20 December, 2022 02:55:35
E2Pdf
Support
Topics: 7
Messages: 3188
Can you try to use the current code please by adding it to your theme functions.php or as a PHP snippet: https://codeshare.io/VZgn1O

After adding the code, use the shortcode inside your E2Pdf Template as:

[e2pdf-wp key="primary_productcategory" meta="true"]

It must output the "primary" selected category name.
We would really appreciate your feedback at WordPress.org!
20 December, 2022 04:30:42
expedientnl
Topics: 1
Messages: 3
This works perfectly, thank you for the help!