我已经看过旧的问题,并尝试了许多不同的方法,似乎是这样做的.我最接近的工作就是这里:如何在自定义WP_Query Ajax上实现分页
我已经尝试了一切,它只是不起作用.页面上绝对没有任何变化.如果你检查加载更多按钮并单击它,jquery正在进行加载更多按钮操作,因为它改变<a id="more_posts">Load More</a>了<a id="more_posts" disables="disabled">Load More</a>,即使这对我来说似乎也没有.它没有添加帖子,我想我错过了一些简单的东西,但对于我的生活,我无法解决它.
我的模板文件中的代码是:
<div id="ajax-posts" class="row">
<?php
$postsPerPage = 3;
$args = [
'post_type' => 'post',
'posts_per_page' => $postsPerPage,
'cat' => 1
];
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post(); ?>
<div class="small-12 large-4 columns">
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
</div>
<?php
endwhile;
echo '<a id="more_posts">Load More</a>';
wp_reset_postdata();
?>
</div>
Run Code Online (Sandbox Code Playgroud)
我的函数文件中的代码是:
function more_post_ajax(){
$offset = $_POST["offset"];
$ppp = $_POST["ppp"];
header("Content-Type: text/html");
$args = [
'suppress_filters' => true, …Run Code Online (Sandbox Code Playgroud) 我搜索了网站,我发现围绕这个主题的唯一线程仍然没有答案,所以我希望我会有更多的运气.
我相对肯定我想做的事情相当容易,但我似乎无法找到答案.
我有一个带有Uitext字段的视图控制器,当单击文本字段时,它会以模态方式显示搜索控制器.
以下是文本字段的代码,即SetAlertTableController.swift:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell
if indexPath.section == 0 {
cell.textLabel!.text = "Set a Station Alert"
cell.backgroundView = UIImageView(image: UIImage(named: "red-full"))
cell.textLabel?.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.0)
cell.imageView!.image = UIImage(named: "metro-no-pad")
cell.textLabel?.textColor = UIColor.whiteColor()
var searchField = UITextField(frame: CGRectMake(60.0, 25.0, 250.0, 30.0))
searchField.backgroundColor = UIColor.whiteColor()
searchField.borderStyle = UITextBorderStyle.Line
searchField.borderStyle = .RoundedRect
searchField.placeholder = "Search Stations"
searchField.textColor = UIColor.lightGrayColor()
searchField.delegate = self
self.view.addSubview(searchField)
} else if indexPath.section …Run Code Online (Sandbox Code Playgroud)