我在使用Wordpress网站的XML RPC编辑帖子时遇到一个小问题。
我使用HTML,PHP和JS。
这段代码可以编辑帖子,但是我只能编辑第一篇帖子。
<?php
session_start();
require_once '../../XXX/wp-load.php';
include '../../XXX/wp-includes/class-IXR.php';
$client = new IXR_Client('http://example.com/xmlrpc.php');
$username = "Login";
$password = "XXX XXX XXX XXX";
$idPost = $_POST['idPost'];
$title = $_POST['title'];
$content = $_POST['content'];
//$tags = $_POST['tags'];
// Update a Selected Post
// The Title of the Post
$content = array('title'=>$title, 'description'=>$content);
$params = array($idPost,$username,$password,$content,1); // First Parameter is mandatory Post Id (get your post id via Recent Blogs entries)
// Run a query for PHP
if (!$client->query('metaWeblog.editPost', $params)) {
die('Something went wrong - '.$client>getErrorCode().' : '.$client->getErrorMessage());
}
session_destroy();
代码PHP-Editpost.php:
<form>
<div class="form-group">
<label for="idPost">Post ID</label>
<input type="text" class="form-control" id="idPost" name="idPost" readonly value="<?php echo $res['postid']; ?>">
</div>
<div class="form-group">
<label for="title">Tytuł</label>
<input type="text" class="form-control" id="title" name="title" value="<?php echo $res['title']; ?>">
</div>
<div class="form-group">
<label for="content">Treść</label>
<textarea type="text" class="form-control" id="content" name="content"><?php echo $res['description']; ?></textarea>
</div>
<div class="form-group">
<label for="tags">Tagi</label>
<input type="text" class="form-control" id="tags" name="tags" value="<?php echo $res['mt_keywords']; ?>">
</div>
<button type="submit" class="submit btn btn-primary">Submit</button>
</form>
Formularz-form.php
if ( event['url'] == '/pk/view/') {
此代码从给定的页面(Wordpress)中检索帖子-感谢我通过此帖子,应该编辑哪些数据。