Products
GG网络技术分享 2025-03-18 16:12 0
I can\'t seem to find an answer anywhere on the web to this, on posts i can do this, i\'m sure there is a native Wordpress function for this. In Wordpress when your editing a \"Page\" and i mean a \"Page\" not a \"Post\", you can assign the page to one or more categories.
I would like to be able to get a list of the categories to which the page is signed to. I know i could ask the DATABASE directly but i\'m sure there is native way to do this. After all it\'s allready implemented in the wordpress own editor.
Im looking for something like this:
$array = get_the_pages_categories($pageID);
Thanks!
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议我无法在网上任何地方找到答案,在帖子上我可以做到这一点,我 我确定有一个原生的Wordpress功能。 在Wordpress中编辑“页面”而我的意思是“页面”而不是“发布”时,您可以将页面分配到一个或多个类别。</ p>
我希望能够 获取页面签名到的类别列表。 我知道我可以直接问DATABASE,但我确信有本地方法可以做到这一点。 毕竟它已经在wordpress自己的编辑器中实现了。</ p>
我正在寻找类似的东西:</ p>
$ array = get_the_pages_categories($ pageID ); </ code> </ pre>
谢谢!</ p>
</ div>
网友观点:
Frist: wp dont have default category for page so you have to create custom taxonomy for page.
register_taxonomy( $taxonomy, $object_type, $args );
check this https://developer.wordpress.org/reference/functions/register_taxonomy/
Next: get that categoies list
$page_terms = get_the_terms( $page_id, $taxonomy );
check this https://developer.wordpress.org/reference/functions/get_the_terms/
i think it will be helpful for you.
Demand feedback