postman chrome在从.net调用wordpress url时显示404错误

In a project, I have to show wp posts in website via .net. So, I created a php file in project root folder as 'latestnews.php'. When called from browser, everything is working fine and data is shown. But in postman though the data is shown status is coming as 404 not found.

How to solve this issue? Any help/suggestions are welcome. Url:


define('WP_USE_THEMES', false);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

$num = $_GET["numberposts"] ?: '10';

$posts = get_posts(array(
    'posts_per_page'   => $num,
$array = array();

foreach($posts as $val) {
    $array[] = array(
            'id' => $val->ID,
            'title' => $val->post_title,
            'link' => get_permalink($val->ID),
            'publish_date' => $val->post_date,
            'content' => strip_tags($val->post_content),
            'image' => get_the_post_thumbnail_url($val->ID, 'full')
echo json_encode($array);
drmeu26880 我尝试使用get和查看请求正常
大约 3 年之前 回复


找到解决方案。</ p>

而不是依次加载wp-blog-header.php 加载wp-load.php(加载wp库)和template-loader.php(加载wp模板),我只添加了wp-load.php。</ p>

所以,我猜wp模板是 创建错误。</ p>
</ div>



Found the solution.

Instead of loading wp-blog-header.php which in turn loads wp-load.php(loads wp library) and template-loader.php(loads wp templates), I added wp-load.php only.

So, I guess wp template was creating the errors.

It is working fine and I am getting below data:

[{"id":2446,"title":"Scientific Programme Committee (SPC)","link":"","publish_date":"2017-02-11 10:23:39","content":"[vc_row][vc_column width=\"1/2\"][vc_column_text] The Scientific Programme Committee (SPC) is comprised of a number of professors, scientists and experts from the water and development fields. The work of the SPC involves setting the overall theme and scope for World Water Week in Stockholm. [/vc_column_text][vc_column_text] The committee also determines the seminars topics, selects from submitted abstracts and develops the seminars programmes.\u00a0 It is aided in its work by the Young Scientific Programme Committee. [/vc_column_text][/vc_column][vc_column width=\"1/2\"][vc_column_text]2017 SPC \tProf. Torkil J\u00f8nch Clausen, DHI (Chair) \tMs. Danka Thalmeinerova, GWP \tDr. Marianne Kjell\u00e9n, UNDP \tDr. Phil Graham, SMHI & BTC \tMs. Renee Andersson, Sustainability Consultant \tDr. Louise Karlberg, SEI (swipe to the next slide to continue)[/vc_column_text][/vc_column][/vc_row]","image":""},{"id":8907,"title":"2017 SPC members (continued)","link":"","publish_date":"2017-02-11 10:21:21","content":"[vc_row][vc_column width=\"1/2\"][vc_column_text](continued 2017 SPC members list) \tDr. Robert Bos, IWA \tMr. Will Sarni, Deloitte \tProf. Kalanithy Vairavamoorthy, IWMI \tMr. Gyewoon Choi, Incheon National University \tMs. Eiman Karar, UNEP \tDr. Guillermo Donoso Harris, Universiad Pontificia \tDr. Diego Rodr\u00edguez, The World Bank Group [/vc_column_text][/vc_column][vc_column width=\"1/2\"][vc_column_text] \tDr. Dipak Gyawali, Nepal Academy of Science and Technology \tMr. Jon Lane, Water and Sanitation Consultant \tMr. Rami AbdelRahman, SIWI \tMs. Pritha Hariram, IWA (co-opted member) \tMr. Victor Arroyo, CAF (co-opted member) \tDr. Pay Drechsel, IWMI (co-opted member) \tMr. Torgny Holmgren, SIWI (Vice Chair) \tMs. Karin Lex\u00e9n, SIWI \tMr. Adrian Puigarnau, SIWI (Secretary) [/vc_column_text][/vc_column][/vc_row]","image":""},{"id":855,"title":"Young Scientific Programme Committee (YPSC)","link":"","publish_date":"2017-02-10 12:10:43","content":"[vc_row][vc_column width=\"1/2\"][vc_column_text]2017 Young Scientific Programme Committee \tShubhra Bhattacharjee, Bangladesh \tMadison Condon, USA \tDavid Ginting, Indonesia \tRianna Gonzales, Trinidad and Tobago [/vc_column_text][/vc_column][vc_column width=\"1/2\"][vc_column_text] \tKanokphan Jongjarb, Thailand \tMarielle Larson, USA \tSofia Murad, USA \tMatthijs Wessels, Holland \tMarij Zwart, The Netherlands [/vc_column_text][/vc_column][/vc_row]","image":""},{"id":4487,"title":"Shubhra Bhattacharjee","link":"","publish_date":"2017-02-10 11:46:49","content":"Shubhra Bhattacharjee is a trained and experienced sustainability professional with a track record of managing complex projects and developing innovative solutions in response to the sustainability challenges faced by business and, in turn, society today. Shubhra joins Solidaridad after an extensive spell of working on the brand side of the sector, with experience working in environmental and social compliances at Lidl HK Ltd., Target Australia and Li & Fung Bangladesh. He audited a number of factories of textile, leather and ceramic sectors. Besides that, a number of training materials on environmental issues was developed by him for factories. He also possesses experience as an environmental manager at a large textile industry. Shubhra holds Bachelor & Master\u2019s degree in Environmental Sciences with concentration in wastewater treatment and public health from Jahangirnagar University, Bangladesh. Shubhra\u2019s interest lies on development of cost effective wastewater treatment and improve water conservation. Shubhra has over 6 years of experience in water and wastewater resource management, treatment, and water conservation. Shubhra specializes on water quality assessment, wastewater treatment and groundwater governance.","image":""},{"id":4485,"title":"Madison Condon","link":"","publish_date":"2017-02-10 11:44:57","content":"Madison Condon is an Earth Institute Postdoctoral Research Fellow at Columbia University where she works in collaboration with the Columbia Water Center and Columbia Law School. She received her J.D. from Harvard University and her Masters in Law and Diplomacy from The Fletcher School at Tufts University. As a Fulbright Fellow based in the Netherlands, she researched the impact of foreign investment on customary water rights in rural Tanzania. Prior to joining the Earth Institute, Madison clerked for Judge Jane Kelly of the Court of Appeals for the Eighth Circuit. She received a B.S. in Environmental Engineering from Columbia University. Madison\u2019s research focuses on environmental law, land and water rights, and international trade and investment law. With the Columbia Water Center and the Columbia Center for Sustainable Investment she is engaged with a three-year project to understand water-related risks in the international mining industry. She also works on a UNESCO-funded project investigating mines the environmental liabilities of state owned mining companies in East Africa.","image":""}]

dpcj40970 这不是一个大问题。
大约 3 年之前 回复
doulian8742 是的,数据正在返回,但邮递员状态表示为404未找到,因此.net end无法处理它。
大约 3 年之前 回复
Csdn user default icon