0
我正在编写一个自定义小部件,通过输入逗号分隔的职位ID列表来显示Wordpress中的一组自定义职位。我不得不检索帖子如下:在Wordpress中检索一组职位
<pre>
if (have_posts()) : while (have_posts()) : the_post();
$postid = get_the_ID();
if (strpos($instance['posts_ids'], (string)$postid) !== false):
show the post
</pre>
不幸的是,这并不总是工作。如果我的ID列表包含ID#12497作为其中之一,则将检索该帖子,但也可能因为字符串匹配而检索ID为249的帖子。
有什么建议吗?
感谢 JA
没有工作。它返回了博客中的所有帖子 – Jay 2014-12-13 07:16:56
我可以使用in_array使其工作。感谢您的提示,它使我在正确的路径 – Jay 2014-12-13 08:14:26
修复,不客气 – merlin 2014-12-13 14:47:11