我目前正在开发Wordpress多站点。虽然我可以使用switch_to_blog(1)从子博客中检索自定义帖子类型,但我无法通过这种方式检索任何自定义分类。
例如,主博客上的此页面列出了“就业”帖子类型中的帖子,并显示与其关联的自定义“位置”类别。
http://209.59.177.85/employment-opportunities/
这个是在儿童博客中,模板代码是在调用switch_to_blog(1)之后:
http://209.59.177.85/waterloo/careers/
相同的代码,但自定义帖子类型显示,而自定义分类则不显示。该页面不会产生任何错误。我甚至无法在分类页面上打印出基本术语列表。
以前有人这样做过吗?
谢谢!
答案 0 :(得分:0)
这是解决方案,万一有人在看。当然,这些术语可以直接从db:
访问<span class="date">Location: <?php
$jobid = get_the_ID();
$queryterms = "
SELECT *
FROM ".$table_prefix."terms terms, ".$table_prefix."term_taxonomy term_taxonomy, ".$table_prefix."term_relationships term_relationships
WHERE (terms.term_id = term_taxonomy.term_id AND term_taxonomy.term_taxonomy_id = term_relationships.term_taxonomy_id)
AND term_relationships.object_id = ".get_the_ID()."
";
$terms = $wpdb->get_results($queryterms, OBJECT);
if ( $terms != null ) {
foreach( $terms as $term ) {
echo "<a href='/location/";
print $term -> slug ;
echo "/'>";
print $term -> name ;
echo "</a>";
unset($term);
} } ?> | Posted on: <?php the_time('F j, Y'); ?></span>