douxing5598 2016-10-14 09:29
浏览 20
已采纳

发布类别重定向问题

I have been asked to look at an issue for a WordPress website which has a post type called Offers. The offers post type has a few categories attached to it, for example food & drink. The categories are all pulled in on the listing page with the following code:

<?php

                //Offers category listing query

                $taxonomy = 'offer_category';
                  $terms = get_terms( $taxonomy, '' );
                  if ($terms) {
                    foreach($terms as $term) {

                        $name = str_replace(' ', '', $term->name);
                        $class = strtolower($name);

                        echo '<a class="title" href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>';
                        echo '<div class="offer category '.$class.'">';
                        echo '<div class="background">';
                        echo '<a class="title" href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>';
                        echo '<h2>'.$term->name.' &raquo;</h2></a>';
                        echo '<span class="count">'. $term->count .'</span>';
                        echo '</a></div></div></a>';
                    }
                  }

                  ?>

The problem is, on the Offers page, if I click the Food & Drink category link, it just keeps redirecting to the Homepage. This happens for any of the categories under the Offers post type. The thing is, when I hover over the link before clicking, the permalink seems to be set correctly, eg: www.mysite.com/offers_category/food-drink/

I have noticed that the site uses a plugin called More Taxonomies but from what I can see in the settings, there is no reference to the homepage or any explanation as to why this would be redirecting to the Homepage.

I'm just not sure where to go from here, I have had a look on the Apache error logs to see if I can find something but I'm at a loss with it.

I would be extremely grateful if you guys could help me out on this one please and I would be happy to provide any further information required to help solve the problem.

Cheers

  • 写回答

1条回答 默认 最新

  • dst8922 2016-10-18 11:03
    关注

    I found the solution, I removed the offer_category from the More Taxonomies items and added the code:

    register_taxonomy('offer_category','offer');

    in manually to register the offer_category taxonomy in the functions.php and the category links now work :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示