get_terms(get_the_ID)显示WP_Error

时间:2019-03-28 17:25:08

标签: wordpress tags taxonomy

我正在尝试从帖子内部显示我的自定义分类标签,但它返回NULL或WP_Error

var_dump(get_terms(get_the_ID()));

// Returns this
object(WP_Error)#6268 (2) { ["errors"]=> array(1) { ["invalid_taxonomy"]=> array(1) { [0]=> string(20) "Taxonomia inválida." } } ["error_data"]=> array(0) { } }

为什么这样说它是无效的分类法?

1 个答案:

答案 0 :(得分:0)

您使用了错误的函数, System.setProperty("webdriver.ie.driver", System.getProperty("user.dir") + ".//src//driver//IEDriverServer.exe"); DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); // this line of code is to resolve protected mode issue capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); driver = new InternetExplorerDriver(capabilities); driver.get("https://10.204.137.86:5111/prweb/PRWebLDAP3/"); 将返回分类法中的术语列表。如果要列出包含自定义分类法的帖子的条款,则需要使用get_terms

get_the_terms

https://developer.wordpress.org/reference/functions/get_the_terms/