0
A
回答
0
数据要想从
GET
参数,您可以使用filter_input()
,或WordPress的get_query_var()
方法的价值。在获得ID后,您可以使用WP_Query
查询帖子并获得 。
$post_id = filter_input(INPUT_GET, 'id');
if (!empty($post_id))
{
$args = [
'post_type' => 'bcworks', //<--replace it with your post_type
'p' => $post_id
];
// The Query
$the_query = new WP_Query($args);
}
else
{
//no post found
}
希望这有助于!
0
为ID使用上一个WordPress取下面的代码
<?php
// would echo post 7's content up until the <!--more--> tag
$post_7 = get_post(7);
$excerpt = $post_7->post_excerpt;
echo $excerpt
// would get post 12's entire content after which you
// can manipulate it with your own trimming preferences
$post_12 = get_post(12);
$trim_me = $post_12->post_content;
my_trim_function($trim_me);
?>
相关问题
- 1. 在Wordpress中获取所有帖子ID
- 2. WordPress的多个帖子从帖子ID
- 3. WordPress的获得帖子ID
- 4. WordPress的获取帖子ID与匹配的帖子内容
- 5. 获取当前帖子的WordPress帖子ID
- 6. 从WordPress中的帖子ID获取固定链接
- 7. 如何从作者ID获取Wordpress帖子的总数?
- 8. 如何从WordPress中的用户ID数组中获取帖子?
- 9. WordPress的帖子ID在wp_nav_menu?
- 10. 从两个类别获取Wordpress帖子
- 11. 获取当前帖子ID
- 12. 如何在Wordpress中的引导模式中获取帖子ID
- 13. 在WordPress的`delete_post`动作中获取帖子ID?
- 14. 如何在WordPress中获取自定义帖子类型ID?
- 15. 如何获取的帖子ID在WordPress模板
- 16. 在WordPress的send_headers动作中获取帖子ID
- 17. 在WordPress中获取帖子摘录
- 18. Fishpig Wordpress - 在帖子列表中获取帖子类别
- 19. 帖子的URL前缀WordPress
- 20. 从url获取ID
- 21. 从每个类别中获取最新帖子,并在wordpress中添加帖子
- 22. 获取所有帖子按类别和代码(从URL参数)在WordPress
- 23. 获取循环外的当前帖子ID。 WordPress的
- 24. WordPress的获取帖子ID与PHP文件
- 25. 获取所有帖子WordPress的JSON与URL
- 26. WordPress的获取帖子AJAX infinate滚动
- 27. WordPress的获取帖子的范围
- 28. WordPress的帖子内容获取地址
- 29. 在wordpress 3.0中从其他网站获取帖子
- 30. 从一个过滤器中获取WordPress发帖ID
如何获得$ the_query –
的帖子标题和内容非常感谢。它效果不错 –
你能帮我过滤器搜索如名称,地址和邮政编码表格搜索 –