douzhangcuo2174 2015-07-14 07:49
浏览 136

WordPress中的Jquery Ajax没有在帖子页面中使用wp-load.php文件

I am using Jquery to post values and get some return values from outside page in my plugin, in that page I am using wp-load.php to access wordpress functionalities. without wp-load.php using in that page how can we get results, here my code of two plugin pages.

Main plugin file having Jquery.

var locations = function () {
    var tmp = null;
        $.ajax({        
        'async': false, 
        'type': "POST",
        dataType: 'json',
        url: "<?php  echo plugins_url( 'json.php', __FILE__  ); ?>",
        data: "post_type="+post_type_loc,
            success: function(data){
                 tmp = data;
            }
        });
           return tmp;
    }();

and Json page having code like this.

<?php
// PHP array
include_once("../../../wp-load.php");
?>
<?php 
$products = array();
$post_type=$_POST['post_type'];
$loop = get_posts('post_type='.$post_type); ?>
<?php foreach ( $loop as $post ) : setup_postdata( $post ); ?>


 <?php endforeach;
wp_reset_postdata();
?>

Is there any other way without using jquery ajax and wp-load.php include to do this.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
    • ¥15 钢筋实图交点识别,机器视觉代码
    • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
    • ¥50 400g qsfp 光模块iphy方案
    • ¥15 两块ADC0804用proteus仿真时,出现异常
    • ¥15 关于风控系统,如何去选择
    • ¥15 这款软件是什么?需要能满足我的需求
    • ¥15 SpringSecurityOauth2登陆前后request不一致