【问题标题】:Add class to current post title in a list将课程添加到列表中的当前帖子标题
【发布时间】:2019-06-04 08:57:11
【问题描述】:

我尝试了这篇文章中的方法。

Add class to current Wordpress Post Title

但这对我不起作用。我在单个 CPT 上显示了我的 cpt 列表。我可以获取当前的帖子 ID,但不能获取列表中所有帖子的 ID。所以 $loop->ID 不返回任何东西。 这里的网址:http://magdakossidas.thomasdesnoyers.com/spectacles/herakles/

谢谢

【问题讨论】:

  • $loop->ID 真的是一个东西吗?以前从未见过。在循环内部,您应该可以简单地使用the_id() resp。 get_the_id(),不是吗?
  • 是的,我最终做到了,并且成功了。

标签: php wordpress


【解决方案1】:

我只是得到了我自己问题的解决方案。我使用 get_the_ID();循环内与循环外的ID进行比较。

$list_post_id = get_the_ID();

【讨论】:

    猜你喜欢
    • 2018-10-16
    • 2019-12-13
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-08
    • 2018-08-03
    相关资源
    最近更新 更多