dongzhuo1930 2013-04-03 10:29
浏览 32

列表结果的条件错误

Apollogies first for what is likely a dumb question. I'm new to Wordpress and PHP so I'm already over my head. I am concerned about this part of the code in lists-categories-posts/default.php which checks if there's a result and give an error if not:

if ( count( $this->catlist->lcp_categories_posts) == 0 )
{
  $lcp_display_output .= '<li>No results</li>';
}

I just need a different error when there is no result but when in a particular category ('news'). I modified the error code but I'm getting identical result.

if ( count( $this->catlist->lcp_categories_posts) == 0 )
{
  if ( in_category( 'news' )) {
    $lcp_display_output .= '<li>No news results</li>';
  } else {
    $lcp_display_output .= '<li>No results</li>';
  }
}

I'm trying to filter the error but it doesn't seem to evaluate the category at all. It always falls to the last else statement.

I really need some help...sigh.

http://wordpress.org/extend/plugins/list-category-posts/

  • 写回答

2条回答 默认 最新

  • dongyinpan9284 2013-04-03 11:00
    关注

    What you do here is first check the lcp_categories_posts if is empty and then you check if it is in the category news.

    I think that this is always going to be false since the lcp_categories_posts will be empty and therefore it will not belong to any category.

    So your check for the category should go somewhere else.

    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口