此问题与wordpress 4.5.3,acf 3.8.8,ajax和php有关。
我有一个自定义字段,其中包含从嵌入了ajax响应的帖子类型中检索的数据。现在,问题是即使我添加<form id="loginF" [formGroup]="loginForm" (ngSubmit)="login()">
...
</form>
<button form="loginF" (click)="submit.click"></button>
,它返回的帖子等于默认的博客帖子号码。我可以排除这个并获得所有帖子吗?
我尝试使用query_posts并发送show posts参数,但不排除默认博客帖子大小。是否可以这样做,因为我只需要在每个页面的帖子中更改管理员posts_per_page => -1
并排除默认博客帖子号码?
if(is_admin())
将数组值与新行程匹配
Return only 10
ajax request code :
$.ajax({
type: "GET",
url: "../wp-content/themes/megaintl/inc/admin.php?post_w=taxonomyTripEdit&tId=" + pId,
async: false,
success: function (data) {
console.log(data);
var results = JSON.parse(data);
//var i = 1;
$.each(results, function (key, data) {
var stringArray = data.split('-');
var selectedKey = stringArray.slice(1).join('-');
//alert(selectedKey);
if (selectedKey != '') {
var selectKey = selectedKey;
$('#acf-field_57b13a3e248ad').append($('<option ' + selectKey + '></option>').val(stringArray[0]).html(stringArray[0]));
} else {
$('#acf-field_57b13a3e248ad').append($('<option></option>').val(data).html(data));
}
});
}
});
admin.php
if(isset($_GET['tId'])) {
$terms = get_terms( array(
'taxonomy' => 'trip_category',
'hide_empty' => false,
) );
foreach ($terms as $term) {
//echo $term->term_id;
if ($term->term_id == $_GET['tId']) {
$category = get_field('category_option_trips', 'trip_category_' . $_GET['tId']);
}
}
$argsTrip = array(
'post_type' => 'trip',
'posts_per_page' => -1
);
// query
$tripSelect = array();
$trip = new WP_Query($argsTrip);
if ($trip) {
while ($trip->have_posts()): $trip->the_post();
if (!empty($category)) {